Browse Source

Add u8glib library supporting dot matrix displays

https://code.google.com/p/u8glib/
Universal Graphics Library for 8 Bit Embedded Systems
Dirk Eichel 11 years ago
parent
commit
c8e2f44087
100 changed files with 107741 additions and 0 deletions
  1. 114
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/ChangeLog
  2. 21
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/INSTALL.TXT
  3. 80
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/U8glib.cpp
  4. 826
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/U8glib.h
  5. 130
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/Bitmap/Bitmap.pde
  6. 180
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/Chess/Chess.pde
  7. 230
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/Console/Console.pde
  8. 139
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/F/F.pde
  9. 223
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/GraphicsTest/GraphicsTest.pde
  10. 136
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/HelloWorld/HelloWorld.pde
  11. 234
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/Menu/Menu.pde
  12. 124
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/PrintTest/PrintTest.pde
  13. 152
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/Rotation/Rotation.pde
  14. 141
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/Scale/Scale.pde
  15. 154
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/TextRotX/TextRotX.pde
  16. 179
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/U8gLogo/U8gLogo.pde
  17. 136
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/XBM/XBM.pde
  18. 80
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/license.txt
  19. 2392
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/chessengine.c
  20. 1606
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g.h
  21. 177
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_bitmap.c
  22. 382
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_circle.c
  23. 156
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_clip.c
  24. 173
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_api.c
  25. 94
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_api_16gr.c
  26. 75
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_common.c
  27. 245
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_fast_parallel.c
  28. 191
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c
  29. 221
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_no_en_parallel.c
  30. 187
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_parallel.c
  31. 168
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_port_d_wr.c
  32. 201
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_ssd_i2c.c
  33. 220
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_st7920_hw_spi.c
  34. 295
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_st7920_spi.c
  35. 144
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_std_sw_spi.c
  36. 239
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_sw_spi.c
  37. 385
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_t6963.c
  38. 174
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_atmega_hw_spi.c
  39. 183
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_atmega_parallel.c
  40. 205
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_atmega_st7920_hw_spi.c
  41. 170
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_atmega_st7920_spi.c
  42. 141
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_atmega_sw_spi.c
  43. 249
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_i2c.c
  44. 218
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_io.c
  45. 63
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_null.c
  46. 99
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_cursor.c
  47. 215
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_delay.c
  48. 92
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_flipdisc_2x7.c
  49. 130
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_gprof.c
  50. 326
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ili9325d_320x240.c
  51. 110
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ks0108_128x64.c
  52. 147
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_lc7981_160x80.c
  53. 145
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_lc7981_240x128.c
  54. 145
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_lc7981_240x64.c
  55. 145
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_lc7981_320x64.c
  56. 67
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_null.c
  57. 110
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_pcd8544_84x48.c
  58. 123
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_pcf8812_96x65.c
  59. 107
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_sbn1661_122x32.c
  60. 247
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1306_128x32.c
  61. 237
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1306_128x64.c
  62. 144
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1309_128x64.c
  63. 334
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1322_nhd31oled_bw.c
  64. 333
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1322_nhd31oled_gr.c
  65. 263
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1325_nhd27oled_bw.c
  66. 232
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1325_nhd27oled_bw_new.c
  67. 255
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1325_nhd27oled_gr.c
  68. 227
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1325_nhd27oled_gr_new.c
  69. 299
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1327_96x96_gr.c
  70. 153
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7565_64128n.c
  71. 140
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7565_dogm128.c
  72. 157
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7565_dogm132.c
  73. 157
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7565_lm6059.c
  74. 188
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7565_lm6063.c
  75. 143
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7565_nhd_c12832.c
  76. 145
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7565_nhd_c12864.c
  77. 420
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7687_c144mvgd.c
  78. 171
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7920_128x64.c
  79. 151
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7920_192x32.c
  80. 154
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7920_202x32.c
  81. 191
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_t6963_128x64.c
  82. 195
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_t6963_240x128.c
  83. 195
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_t6963_240x64.c
  84. 115
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_tls8204_84x48.c
  85. 290
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_uc1610_dogxl160.c
  86. 113
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_uc1701_dogs102.c
  87. 114
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_uc1701_mini12864.c
  88. 100
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_ellipse.c
  89. 1422
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_font.c
  90. 84486
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_font_data.c
  91. 81
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_line.c
  92. 456
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_ll_api.c
  93. 81
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_page.c
  94. 191
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_pb.c
  95. 200
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_pb14v1.c
  96. 213
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_pb16h1.c
  97. 182
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_pb16h2.c
  98. 200
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_pb16v1.c
  99. 172
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_pb16v2.c
  100. 0
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_pb32h1.c

+ 114
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/ChangeLog View File

@@ -0,0 +1,114 @@
1
+
2
+u8glib ChangeLog
3
+
4
+2012-01-01      v0.01   Oliver Kraus <olikraus@gmail.com>
5
+  * first beta release for Arduino IDE with simple SSD1325 support
6
+2012-01-04      v0.02   Oliver Kraus <olikraus@gmail.com>
7
+  * support for some more display types
8
+2012-01-07      v0.03   Oliver Kraus <olikraus@gmail.com>
9
+  * fixed some bugs, added more examples
10
+2012-01-07      v0.04   Oliver Kraus <olikraus@gmail.com>
11
+  * single font file
12
+2012-01-08      v0.05   Oliver Kraus <olikraus@gmail.com>
13
+  * Cleanup
14
+  * More examples
15
+  * SSD1325 graylevel support
16
+2012-01-15      v0.06   Oliver Kraus <olikraus@gmail.com>
17
+  * LM6063 support
18
+2012-01-17      v0.07   Oliver Kraus <olikraus@gmail.com>
19
+  * LM6063 support (update)
20
+2012-01-19      v0.08   Oliver Kraus <olikraus@gmail.com>
21
+  * ST7920 beta device
22
+2012-01-21      v0.09   Oliver Kraus <olikraus@gmail.com>
23
+  * ST7920 fixed (192x32)
24
+  * fixed bug in com layer if pins are none
25
+  * str reference position
26
+2012-01-22      v0.10   Oliver Kraus <olikraus@gmail.com>
27
+  * Experimental LM6059 
28
+2012-01-24      v0.11   Oliver Kraus <olikraus@gmail.com>
29
+  * new st7920 memory layout for 128x64 lcd
30
+  * experimental st7920 SPI
31
+2012-01-25      v0.12   Oliver Kraus <olikraus@gmail.com>
32
+  * fixed st7920 memory layout for 128x64 lcd
33
+  * ST7920 SPI performance improvement
34
+2012-01-27	v0.13	Oliver Kraus <olikraus@gmail.com>
35
+  * LM6059 (Adafruit Display) fixed
36
+2012-02-01	v0.14	Oliver Kraus <olikraus@gmail.com>
37
+  * undoRotation()
38
+  * setRot..() can be used without restrictions
39
+  * Class U8GLIB derived from Print class. New function "print" 
40
+  * Fixed memory index bug in the page management procedures
41
+2012-02-12      v1.00	Oliver Kraus <olikraus@gmail.com>
42
+  * XBM support
43
+  * F() macro support
44
+  * str-rotation commands support ref-height and ref-position
45
+2012-03-17      v1.02	Oliver Kraus <olikraus@gmail.com>
46
+  * U8GLIB_ST7687_C144MVGD spi experimental
47
+  * U8GLIB_LC7981_160X80 8bit
48
+  * Intersection test for frame and box procedures
49
+  * 4L double memory architecture  
50
+  * setContrast infrastructure implemented, but not available for all devices
51
+  * drawCircle, drawDisc
52
+  * Bugfix for drawStr270
53
+  * New examples: Chess (ported from dogm128 lib) and GraphicsTest
54
+2012-03-31      v1.03	Oliver Kraus <olikraus@gmail.com>
55
+  * experimental parallel mode atmega
56
+  * more unifont code pages
57
+  * double memory, for NHD OLED and DOGXL160
58
+  * "Menu" example
59
+  * drawLine
60
+2012-04-13      v1.04	Oliver Kraus <olikraus@gmail.com>
61
+  * Adjust U8grelease: Same version number with AVR and Arduino variant
62
+2012-06-10	v1.05	Oliver Kraus <olikraus@gmail.com>
63
+  * m2icon font
64
+  * experimental lc7981_240x64 device
65
+  * experimental ssd1306
66
+  * experimental ssd1322
67
+  * Hardware state backup/restore procedure
68
+2012-06-15	v1.06	Oliver Kraus <olikraus@gmail.com>
69
+  * SBN1661 (SED1520?) support
70
+  * SSD1306 support
71
+  * U8G_PROGMEM bugfix
72
+2012-07-04	v1.07	Oliver Kraus <olikraus@gmail.com>
73
+  * Added Makefiles for AVR release (issue 77)
74
+  * Fixed examples for Arduino Environment (issue 78)
75
+2012-10-02	v1.08	Oliver Kraus <olikraus@gmail.com>
76
+  * Improved delay calculation for strobe pulse (issue 20)
77
+  * Support Chipkit (issue 39)
78
+  * Improved speed for ST7920 parallel mode (issue 79)
79
+  * Overall speed optimization (new page intersection algorithm)
80
+  * Support for Displays Newhaven NHD-C12864, CrystalFontz GFAG20232, Seeedstudio 96x96 OLED
81
+  * Added SPI support for ST7920 with plain AVR (issue 85)
82
+  * Add more LC7981 devices
83
+2012-12-23	v1.09	  Oliver Kraus <olikraus@gmail.com>
84
+  * Support for Displaytech 64128n
85
+  * Support for MINI12864
86
+  * HW SPI for ST7920
87
+  * Add delay after sending a byte with (ST7920 com)
88
+  * Support ATTiny
89
+  * Support I2C for SSD1306
90
+  * bdf2u8g, Windows executable released
91
+  * LC7981 320x64
92
+  * Scalue up: u8g::setScale2x2
93
+  * Added more bitmap fonts
94
+  * u8g::drawRBox(), u8g::drawRFrame()
95
+  * Support for CFAG20232 (st7920_202x32)
96
+  * Fixed ST7920 SW SPI for ChipKit
97
+  * Support for tls8204
98
+2013-02-02	v1.10	  Oliver Kraus <olikraus@gmail.com>
99
+  * Support for SSD1309
100
+  * Support for NHD-C12832A1Z 
101
+  * Bugfix: Fixed reset controll in parallel modes
102
+  * Bugfix: Fixed calculation of cursor position
103
+  * Bugfix: ST7920 parallel mode
104
+2013-03-2	v1.11	  Oliver Kraus <olikraus@gmail.com>
105
+  * Support for T6963
106
+  * Support for Arduino Due
107
+  * Sleep Mode
108
+  * 4x mode for ST7920
109
+  * New C++ interface for ST7920 
110
+
111
+  
112
+  
113
+  
114
+  

+ 21
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/INSTALL.TXT View File

@@ -0,0 +1,21 @@
1
+
2
+U8GLIB
3
+http://code.google.com/p/u8glib/
4
+
5
+
6
+Install instructions for the Arduino environment.
7
+
8
+  1. Unzip u8glib_arduino_vX.XX.zip into the "libraries" folder
9
+  2. Start Arduino IDE
10
+
11
+Install instructions for the Chipkit (Arduino) environment.
12
+
13
+  1. cd <mpide-... path>/libraries
14
+  2. unzip u8glib_arduino_vX.XX.zip
15
+  3. cd <mpide-... path>///hardware/pic32/libraries
16
+  4. again: u8glib_arduino_vX.XX.zip
17
+  5. Open hardware/pic32/cores/pic32/Print.h
18
+	  Remove line
19
+	    #define BYTE 0
20
+	  from the file, use PRINT_BYTE instead of BYTE. 
21
+	

+ 80
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/U8glib.cpp View File

@@ -0,0 +1,80 @@
1
+/*
2
+
3
+  U8glib.cpp
4
+
5
+  C++ Interface
6
+
7
+  Universal 8bit Graphics Library
8
+  
9
+  Copyright (c) 2011, olikraus@gmail.com
10
+  All rights reserved.
11
+
12
+  Redistribution and use in source and binary forms, with or without modification, 
13
+  are permitted provided that the following conditions are met:
14
+
15
+  * Redistributions of source code must retain the above copyright notice, this list 
16
+    of conditions and the following disclaimer.
17
+    
18
+  * Redistributions in binary form must reproduce the above copyright notice, this 
19
+    list of conditions and the following disclaimer in the documentation and/or other 
20
+    materials provided with the distribution.
21
+
22
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
23
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
24
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
25
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
26
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
27
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
28
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
29
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
30
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
31
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
32
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
33
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
34
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
35
+
36
+*/
37
+
38
+#include "U8glib.h"
39
+
40
+
41
+
42
+uint8_t U8GLIB::initSPI(u8g_dev_t *dev, uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset)
43
+{
44
+  prepare();
45
+  return u8g_InitSPI(&u8g, dev, sck, mosi, cs, a0, reset);
46
+}
47
+
48
+uint8_t U8GLIB::initHWSPI(u8g_dev_t *dev, uint8_t cs, uint8_t a0, uint8_t reset)
49
+{
50
+  prepare();
51
+  return u8g_InitHWSPI(&u8g, dev, cs, a0, reset);
52
+}
53
+
54
+uint8_t U8GLIB::initI2C(u8g_dev_t *dev, uint8_t options)
55
+{
56
+  prepare();
57
+  return u8g_InitI2C(&u8g, dev, options);
58
+}
59
+
60
+uint8_t U8GLIB::init8Bit(u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
61
+    uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw, uint8_t reset)
62
+{
63
+  prepare();
64
+  return u8g_Init8Bit(&u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset); 
65
+}
66
+
67
+uint8_t U8GLIB::init8BitFixedPort(u8g_dev_t *dev, uint8_t en, uint8_t cs, uint8_t di, uint8_t rw, uint8_t reset)
68
+{
69
+  prepare();
70
+  return u8g_Init8BitFixedPort(&u8g, dev, en, cs, di, rw, reset);
71
+}
72
+
73
+uint8_t U8GLIB::initRW8Bit(u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
74
+    uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset)
75
+{
76
+  prepare();
77
+  return u8g_InitRW8Bit(&u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, cs, a0, wr, rd, reset); 
78
+}
79
+
80
+

+ 826
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/U8glib.h View File

@@ -0,0 +1,826 @@
1
+/*
2
+
3
+  U8glib.h
4
+  
5
+  C++ Interface
6
+
7
+  Universal 8bit Graphics Library
8
+  
9
+  Copyright (c) 2011, olikraus@gmail.com
10
+  All rights reserved.
11
+
12
+  Redistribution and use in source and binary forms, with or without modification, 
13
+  are permitted provided that the following conditions are met:
14
+
15
+  * Redistributions of source code must retain the above copyright notice, this list 
16
+    of conditions and the following disclaimer.
17
+    
18
+  * Redistributions in binary form must reproduce the above copyright notice, this 
19
+    list of conditions and the following disclaimer in the documentation and/or other 
20
+    materials provided with the distribution.
21
+
22
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
23
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
24
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
25
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
26
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
27
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
28
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
29
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
30
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
31
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
32
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
33
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
34
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
35
+
36
+*/
37
+
38
+#ifndef _CPP_U8GLIB
39
+#define _CPP_U8GLIB
40
+
41
+#include <Print.h>
42
+#include "utility/u8g.h"
43
+
44
+
45
+class U8GLIB : public Print
46
+{
47
+  private:
48
+    u8g_t u8g;
49
+    u8g_uint_t tx, ty;          // current position for the Print base class procedures
50
+    uint8_t is_begin;
51
+
52
+    void prepare(void) { tx = 0; ty = 0; is_begin = 0; }
53
+    void cbegin(void) { if ( is_begin == 0 ) { is_begin = 1; u8g_Begin(&u8g); } }
54
+    uint8_t initSPI(u8g_dev_t *dev, uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE);
55
+    uint8_t initHWSPI(u8g_dev_t *dev, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE);
56
+    uint8_t initI2C(u8g_dev_t *dev, uint8_t options);
57
+  protected:
58
+    uint8_t init8BitFixedPort(u8g_dev_t *dev, uint8_t en, uint8_t cs, uint8_t di, uint8_t rw, uint8_t reset);
59
+  private:
60
+    uint8_t init8Bit(u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
61
+        uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE);
62
+    uint8_t initRW8Bit(u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
63
+      uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset);
64
+  public:
65
+  
66
+    /* constructor */
67
+    U8GLIB(void)
68
+      { }
69
+    U8GLIB(u8g_dev_t *dev)
70
+      { prepare(); u8g_Init(&u8g, dev); }
71
+    U8GLIB(u8g_dev_t *dev, uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset) 
72
+      { initSPI(dev, sck, mosi, cs, a0, reset); }
73
+    U8GLIB(u8g_dev_t *dev, uint8_t cs, uint8_t a0, uint8_t reset) 
74
+      { initHWSPI(dev, cs, a0, reset); }
75
+    U8GLIB(u8g_dev_t *dev, uint8_t options) 
76
+      { initI2C(dev, options); }
77
+    U8GLIB(u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
78
+        uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw, uint8_t reset) 
79
+      { init8Bit(dev, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset); }
80
+    U8GLIB(u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
81
+        uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset) 
82
+      { initRW8Bit(dev, d0, d1, d2, d3, d4, d5, d6, d7, cs, a0, wr, rd, reset); }
83
+
84
+    uint8_t begin(void) { is_begin = 1; return u8g_Begin(&u8g); }
85
+      
86
+    void setPrintPos(u8g_uint_t x, u8g_uint_t y) { tx = x; ty = y; }
87
+    u8g_t *getU8g(void) { return &u8g; }
88
+    
89
+    
90
+    /* implementation of the write interface to the print class */
91
+#if defined(ARDUINO) && ARDUINO >= 100
92
+    size_t write(uint8_t c) { tx += u8g_DrawGlyph(&u8g, tx, ty, c); return 1;}
93
+#else
94
+    void write(uint8_t c) { tx += u8g_DrawGlyph(&u8g, tx, ty, c); }
95
+#endif
96
+    
97
+     /* screen rotation */
98
+    void undoRotation(void) { u8g_UndoRotation(&u8g); }
99
+    void setRot90(void) { u8g_SetRot90(&u8g); }
100
+    void setRot180(void) { u8g_SetRot180(&u8g); }
101
+    void setRot270(void) { u8g_SetRot270(&u8g); }
102
+
103
+     /* screen scaling */
104
+    void undoScale(void) { u8g_UndoScale(&u8g); }
105
+    void setScale2x2(void) { u8g_SetScale2x2(&u8g); }
106
+    
107
+     /* picture loop */
108
+    void firstPage(void) { cbegin(); u8g_FirstPage(&u8g); }
109
+    uint8_t nextPage(void) { return u8g_NextPage(&u8g); }
110
+    
111
+    /* system commands */
112
+    uint8_t setContrast(uint8_t contrast) { cbegin(); return u8g_SetContrast(&u8g, contrast); }
113
+    void sleepOn(void) { u8g_SleepOn(&u8g); }
114
+    void sleepOff(void) { u8g_SleepOff(&u8g); }
115
+    
116
+    /* graphic primitives */
117
+    void setColorIndex(uint8_t color_index) { u8g_SetColorIndex(&u8g, color_index); }
118
+    uint8_t getColorIndex(void) { return u8g_GetColorIndex(&u8g); }
119
+    
120
+    void setDefaultForegroundColor(void) { u8g_SetDefaultForegroundColor(&u8g);  }
121
+    void setDefaultBackgroundColor(void) { u8g_SetDefaultBackgroundColor(&u8g);  }
122
+    void setDefaultMidColor(void) { u8g_SetDefaultMidColor(&u8g);  }
123
+    
124
+    u8g_uint_t getWidth(void) { return u8g_GetWidth(&u8g); }
125
+    u8g_uint_t getHeight(void) { return u8g_GetHeight(&u8g); }
126
+    uint8_t getMode(void) { return u8g_GetMode(&u8g); }
127
+
128
+    void drawPixel(u8g_uint_t x, u8g_uint_t y) { return u8g_DrawPixel(&u8g, x, y); }
129
+    void drawHLine(u8g_uint_t x, u8g_uint_t y, u8g_uint_t w) { u8g_DrawHLine(&u8g, x, y, w); }  
130
+    void drawVLine(u8g_uint_t x, u8g_uint_t y, u8g_uint_t h) { u8g_DrawVLine(&u8g, x, y, h); }
131
+    void drawLine(u8g_uint_t x1, u8g_uint_t y1, u8g_uint_t x2, u8g_uint_t y2) { u8g_DrawLine(&u8g, x1, y1, x2, y2); }
132
+    
133
+    void drawFrame(u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h) { u8g_DrawFrame(&u8g, x, y, w, h); }
134
+    void drawRFrame(u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, u8g_uint_t r) { u8g_DrawRFrame(&u8g, x, y, w, h,r); }
135
+    void drawBox(u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h) { u8g_DrawBox(&u8g, x, y, w, h); }
136
+    void drawRBox(u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, u8g_uint_t r) { u8g_DrawRBox(&u8g, x, y, w, h,r); }
137
+
138
+    void drawCircle(u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t opt = U8G_DRAW_ALL) { u8g_DrawCircle(&u8g, x0, y0, rad, opt); }
139
+    void drawDisc(u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t opt = U8G_DRAW_ALL) { u8g_DrawDisc(&u8g, x0, y0, rad, opt); }
140
+     
141
+    /* bitmap handling */
142
+    void drawBitmap(u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, u8g_uint_t h, const uint8_t *bitmap) 
143
+      { u8g_DrawBitmap(&u8g, x, y, cnt, h, bitmap); }
144
+    void drawBitmapP(u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, u8g_uint_t h, const u8g_pgm_uint8_t *bitmap)
145
+      { u8g_DrawBitmapP(&u8g, x, y, cnt, h, bitmap); }
146
+
147
+    void drawXBM(u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, const uint8_t *bitmap)
148
+      { u8g_DrawXBM(&u8g, x, y, w, h, bitmap); }
149
+    void drawXBMP(u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, const u8g_pgm_uint8_t *bitmap)
150
+      { u8g_DrawXBMP(&u8g, x, y, w, h, bitmap); }
151
+    
152
+      
153
+    /* font handling */
154
+    void setFont(const u8g_fntpgm_uint8_t *font) {u8g_SetFont(&u8g, font); }
155
+    int8_t getFontAscent(void) { return u8g_GetFontAscent(&u8g); }
156
+    int8_t getFontDescent(void) { return u8g_GetFontDescent(&u8g); }
157
+    int8_t getFontLineSpacing(void) { return u8g_GetFontLineSpacing(&u8g); }
158
+    
159
+    u8g_uint_t drawStr(u8g_uint_t x, u8g_uint_t y, const char *s) { return u8g_DrawStr(&u8g, x, y, s); }
160
+    u8g_uint_t drawStr90(u8g_uint_t x, u8g_uint_t y, const char *s) { return u8g_DrawStr90(&u8g, x, y, s); }
161
+    u8g_uint_t drawStr180(u8g_uint_t x, u8g_uint_t y, const char *s) { return u8g_DrawStr180(&u8g, x, y, s); }
162
+    u8g_uint_t drawStr270(u8g_uint_t x, u8g_uint_t y, const char *s) { return u8g_DrawStr270(&u8g, x, y, s); }
163
+    u8g_uint_t drawStrP(u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s) { return u8g_DrawStrP(&u8g, x, y, s); }
164
+    u8g_uint_t drawStr90P(u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s) { return u8g_DrawStr90P(&u8g, x, y, s); }
165
+    u8g_uint_t drawStr180P(u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s) { return u8g_DrawStr180P(&u8g, x, y, s); }
166
+    u8g_uint_t drawStr270P(u8g_uint_t x, u8g_uint_t y, const u8g_pgm_uint8_t *s) { return u8g_DrawStr270P(&u8g, x, y, s); }
167
+    
168
+    void setFontPosBaseline(void) { u8g_SetFontPosBaseline(&u8g); }
169
+    void setFontPosBottom(void) { u8g_SetFontPosBottom(&u8g); }
170
+    void setFontPosCenter(void) { u8g_SetFontPosCenter(&u8g); }
171
+    void setFontPosTop(void) { u8g_SetFontPosTop(&u8g); }
172
+
173
+    void setFontRefHeightText(void) { u8g_SetFontRefHeightText(&u8g); }
174
+    void setFontRefHeightExtendedText(void) { u8g_SetFontRefHeightExtendedText(&u8g); }
175
+    void setFontRefHeightAll(void) { u8g_SetFontRefHeightAll(&u8g); }  
176
+    void setFontLineSpacingFactor(uint8_t factor) { u8g_SetFontLineSpacingFactor(&u8g, factor); }
177
+
178
+
179
+    u8g_uint_t getStrPixelWidth(const char *s) { return u8g_GetStrPixelWidth(&u8g, s); }
180
+    u8g_uint_t getStrPixelWidthP(u8g_pgm_uint8_t *s) { return u8g_GetStrPixelWidthP(&u8g, s); }
181
+    u8g_uint_t getStrWidth(const char *s) { return u8g_GetStrWidth(&u8g, s); } 
182
+    u8g_uint_t getStrWidthP(u8g_pgm_uint8_t *s) { return u8g_GetStrWidthP(&u8g, s); }
183
+    
184
+    void setHardwareBackup(u8g_state_cb backup_cb) { u8g_SetHardwareBackup(&u8g, backup_cb); }
185
+    
186
+#if defined(ARDUINO) && ARDUINO >= 100
187
+    // support for the F() macro
188
+    
189
+    u8g_uint_t drawStr(u8g_uint_t x, u8g_uint_t y, const __FlashStringHelper *s) { return u8g_DrawStrP(&u8g, x, y, (u8g_pgm_uint8_t *)s); }
190
+    u8g_uint_t drawStr90(u8g_uint_t x, u8g_uint_t y, const __FlashStringHelper *s) { return u8g_DrawStr90P(&u8g, x, y, (u8g_pgm_uint8_t *)s); }
191
+    u8g_uint_t drawStr180(u8g_uint_t x, u8g_uint_t y, const __FlashStringHelper *s) { return u8g_DrawStr180P(&u8g, x, y, (u8g_pgm_uint8_t *)s); }
192
+    u8g_uint_t drawStr270(u8g_uint_t x, u8g_uint_t y, const __FlashStringHelper *s) { return u8g_DrawStr270P(&u8g, x, y, (u8g_pgm_uint8_t *)s); }
193
+    
194
+    u8g_uint_t getStrPixelWidth(const __FlashStringHelper *s) { return u8g_GetStrPixelWidthP(&u8g, (u8g_pgm_uint8_t *)s); }
195
+    u8g_uint_t getStrWidth(const __FlashStringHelper *s) { return u8g_GetStrWidthP(&u8g, (u8g_pgm_uint8_t *)s); }
196
+#endif
197
+
198
+    /* cursor handling */
199
+    void setCursorFont(const u8g_pgm_uint8_t *cursor_font) { u8g_SetCursorFont(&u8g, cursor_font); }
200
+    void setCursorStyle(uint8_t encoding) { u8g_SetCursorStyle(&u8g, encoding); }
201
+    void setCursorPos(u8g_uint_t cursor_x, u8g_uint_t cursor_y) { u8g_SetCursorPos(&u8g, cursor_x, cursor_y); }
202
+    void setCursorColor(uint8_t fg, uint8_t bg) { u8g_SetCursorColor(&u8g, fg, bg); }
203
+    void enableCursor(void) { u8g_EnableCursor(&u8g); }
204
+    void disableCursor(void) { u8g_DisableCursor(&u8g); }
205
+    void drawCursor(void)  { u8g_DrawCursor(&u8g); }
206
+    
207
+    /* virtual screen */
208
+    
209
+    void setVirtualScreenDimension(u8g_uint_t width, u8g_uint_t height) { u8g_SetVirtualScreenDimension(&u8g, width, height); }
210
+    uint8_t addToVirtualScreen(u8g_uint_t x, u8g_uint_t y, U8GLIB &child_u8g) { return u8g_AddToVirtualScreen(&u8g, x, y, &child_u8g.u8g); }
211
+
212
+};
213
+
214
+
215
+class U8GLIB_DOGS102 : public U8GLIB 
216
+{
217
+  public:
218
+    U8GLIB_DOGS102(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
219
+      : U8GLIB(&u8g_dev_uc1701_dogs102_sw_spi, sck, mosi, cs, a0, reset)
220
+      { }
221
+    U8GLIB_DOGS102(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
222
+      : U8GLIB(&u8g_dev_uc1701_dogs102_hw_spi, cs, a0, reset)
223
+      { }
224
+};
225
+
226
+class U8GLIB_MINI12864 : public U8GLIB 
227
+{
228
+  public:
229
+    U8GLIB_MINI12864(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
230
+      : U8GLIB(&u8g_dev_uc1701_mini12864_sw_spi, sck, mosi, cs, a0, reset)
231
+      { }
232
+    U8GLIB_MINI12864(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
233
+      : U8GLIB(&u8g_dev_uc1701_mini12864_hw_spi, cs, a0, reset)
234
+      { }
235
+};
236
+
237
+class U8GLIB_DOGM132 : public U8GLIB 
238
+{
239
+  public:
240
+    U8GLIB_DOGM132(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
241
+      : U8GLIB(&u8g_dev_st7565_dogm132_sw_spi, sck, mosi, cs, a0, reset)
242
+      { }
243
+    U8GLIB_DOGM132(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
244
+      : U8GLIB(&u8g_dev_st7565_dogm132_hw_spi, cs, a0, reset)
245
+      { }
246
+};
247
+
248
+class U8GLIB_NHD_C12832 : public U8GLIB 
249
+{
250
+  public:
251
+    U8GLIB_NHD_C12832(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
252
+      : U8GLIB(&u8g_dev_st7565_nhd_c12832_sw_spi, sck, mosi, cs, a0, reset)
253
+      { }
254
+    U8GLIB_NHD_C12832(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
255
+      : U8GLIB(&u8g_dev_st7565_nhd_c12832_hw_spi, cs, a0, reset)
256
+      { }
257
+    U8GLIB_NHD_C12832(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
258
+        uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) 
259
+      : U8GLIB(&u8g_dev_st7565_nhd_c12832_parallel, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, U8G_PIN_NONE, di, rw, reset)
260
+      { }
261
+};
262
+
263
+class U8GLIB_DOGM128 : public U8GLIB 
264
+{
265
+  public:
266
+    U8GLIB_DOGM128(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
267
+      : U8GLIB(&u8g_dev_st7565_dogm128_sw_spi, sck, mosi, cs, a0, reset)
268
+      { }
269
+    U8GLIB_DOGM128(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
270
+      : U8GLIB(&u8g_dev_st7565_dogm128_hw_spi, cs, a0, reset)
271
+      { }
272
+};
273
+
274
+class U8GLIB_LM6059 : public U8GLIB 
275
+{
276
+  public:
277
+    U8GLIB_LM6059(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
278
+      : U8GLIB(&u8g_dev_st7565_lm6059_sw_spi, sck, mosi, cs, a0, reset)
279
+      { }
280
+    U8GLIB_LM6059(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
281
+      : U8GLIB(&u8g_dev_st7565_lm6059_hw_spi, cs, a0, reset)
282
+      { }
283
+};
284
+
285
+class U8GLIB_LM6063 : public U8GLIB 
286
+{
287
+  public:
288
+    U8GLIB_LM6063(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
289
+      : U8GLIB(&u8g_dev_st7565_lm6063_sw_spi, sck, mosi, cs, a0, reset)
290
+      { }
291
+    U8GLIB_LM6063(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
292
+      : U8GLIB(&u8g_dev_st7565_lm6063_hw_spi, cs, a0, reset)
293
+      { }
294
+};
295
+
296
+class U8GLIB_64128N : public U8GLIB 
297
+{
298
+  public:
299
+    U8GLIB_64128N(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
300
+      : U8GLIB(&u8g_dev_st7565_64128n_sw_spi, sck, mosi, cs, a0, reset)
301
+      { }
302
+    U8GLIB_64128N(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
303
+      : U8GLIB(&u8g_dev_st7565_64128n_hw_spi, cs, a0, reset)
304
+      { }
305
+};
306
+
307
+class U8GLIB_NHD_C12864 : public U8GLIB 
308
+{
309
+  public:
310
+    U8GLIB_NHD_C12864(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
311
+      : U8GLIB(&u8g_dev_st7565_nhd_c12864_sw_spi, sck, mosi, cs, a0, reset)
312
+      { }
313
+    U8GLIB_NHD_C12864(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
314
+      : U8GLIB(&u8g_dev_st7565_nhd_c12864_hw_spi, cs, a0, reset)
315
+      { }
316
+};
317
+
318
+
319
+class U8GLIB_ST7920_128X64 : public U8GLIB 
320
+{
321
+  public:
322
+    U8GLIB_ST7920_128X64(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
323
+      : U8GLIB(&u8g_dev_st7920_128x64_sw_spi, sck, mosi, cs, a0, reset)
324
+      { }
325
+    U8GLIB_ST7920_128X64(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
326
+      : U8GLIB(&u8g_dev_st7920_128x64_hw_spi, cs, a0, reset)
327
+      { }
328
+    U8GLIB_ST7920_128X64(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
329
+        uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) 
330
+      : U8GLIB(&u8g_dev_st7920_128x64_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset)
331
+      { }
332
+    // U8GLIB_ST7920_128X64(uint8_t cs) 
333
+    //   : U8GLIB(&u8g_dev_st7920_128x64_sw_spi, cs, U8G_PIN_NONE, U8G_PIN_NONE)
334
+    //   { }
335
+};
336
+
337
+class U8GLIB_ST7920_128X64_1X : public U8GLIB 
338
+{
339
+  public:
340
+    U8GLIB_ST7920_128X64_1X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t reset = U8G_PIN_NONE) 
341
+      : U8GLIB(&u8g_dev_st7920_128x64_sw_spi, sck, mosi, cs, U8G_PIN_NONE, reset)		// a0 = U8G_PIN_NONE
342
+      { }
343
+    U8GLIB_ST7920_128X64_1X(uint8_t cs, uint8_t reset = U8G_PIN_NONE) 
344
+      : U8GLIB(&u8g_dev_st7920_128x64_hw_spi, cs, U8G_PIN_NONE, reset)			// a0 = U8G_PIN_NONE
345
+      { }
346
+    U8GLIB_ST7920_128X64_1X(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
347
+        uint8_t en, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) 
348
+      : U8GLIB(&u8g_dev_st7920_128x64_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, U8G_PIN_NONE, U8G_PIN_NONE, di, rw, reset)  // cs1 = cs2 = U8G_PIN_NONE
349
+      { }
350
+};
351
+
352
+class U8GLIB_ST7920_128X64_4X : public U8GLIB 
353
+{
354
+  public:
355
+    U8GLIB_ST7920_128X64_4X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t reset = U8G_PIN_NONE) 
356
+      : U8GLIB(&u8g_dev_st7920_128x64_4x_sw_spi, sck, mosi, cs, U8G_PIN_NONE, reset)		// a0 = U8G_PIN_NONE
357
+      { }
358
+    U8GLIB_ST7920_128X64_4X(uint8_t cs, uint8_t reset = U8G_PIN_NONE) 
359
+      : U8GLIB(&u8g_dev_st7920_128x64_4x_hw_spi, cs, U8G_PIN_NONE, reset)			// a0 = U8G_PIN_NONE
360
+      { }
361
+    U8GLIB_ST7920_128X64_4X(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
362
+        uint8_t en, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) 
363
+      : U8GLIB(&u8g_dev_st7920_128x64_4x_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, U8G_PIN_NONE, U8G_PIN_NONE, di, rw, reset)   // cs1 = cs2 = U8G_PIN_NONE
364
+      { }
365
+};
366
+
367
+
368
+
369
+class U8GLIB_ST7920_192X32 : public U8GLIB  // OBSOLETE, use U8GLIB_ST7920_192X32_1X instead
370
+{ 
371
+  public:
372
+    U8GLIB_ST7920_192X32(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
373
+      : U8GLIB(&u8g_dev_st7920_192x32_sw_spi, sck, mosi, cs, a0, reset)
374
+      { }
375
+    U8GLIB_ST7920_192X32(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
376
+      : U8GLIB(&u8g_dev_st7920_192x32_hw_spi, cs, a0, reset)
377
+      { }
378
+    U8GLIB_ST7920_192X32(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
379
+        uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) 
380
+      : U8GLIB(&u8g_dev_st7920_192x32_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset)
381
+      { }
382
+};
383
+
384
+class U8GLIB_ST7920_192X32_1X : public U8GLIB 
385
+{
386
+  public:
387
+    U8GLIB_ST7920_192X32_1X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t reset = U8G_PIN_NONE) 
388
+      : U8GLIB(&u8g_dev_st7920_192x32_sw_spi, sck, mosi, cs, U8G_PIN_NONE, reset)		// a0 = U8G_PIN_NONE
389
+      { }
390
+    U8GLIB_ST7920_192X32_1X(uint8_t cs, uint8_t reset = U8G_PIN_NONE) 
391
+      : U8GLIB(&u8g_dev_st7920_192x32_hw_spi, cs, U8G_PIN_NONE, reset)			// a0 = U8G_PIN_NONE
392
+      { }
393
+    U8GLIB_ST7920_192X32_1X(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
394
+        uint8_t en, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) 
395
+      : U8GLIB(&u8g_dev_st7920_192x32_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, U8G_PIN_NONE, U8G_PIN_NONE, di, rw, reset)  // cs1 = cs2 = U8G_PIN_NONE
396
+      { }
397
+};
398
+
399
+class U8GLIB_ST7920_192X32_4X : public U8GLIB 
400
+{
401
+  public:
402
+    U8GLIB_ST7920_192X32_4X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t reset = U8G_PIN_NONE) 
403
+      : U8GLIB(&u8g_dev_st7920_192x32_4x_sw_spi, sck, mosi, cs, U8G_PIN_NONE, reset)		// a0 = U8G_PIN_NONE
404
+      { }
405
+    U8GLIB_ST7920_192X32_4X(uint8_t cs, uint8_t reset = U8G_PIN_NONE) 
406
+      : U8GLIB(&u8g_dev_st7920_192x32_4x_hw_spi, cs, U8G_PIN_NONE, reset)			// a0 = U8G_PIN_NONE
407
+      { }
408
+    U8GLIB_ST7920_192X32_4X(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
409
+        uint8_t en, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) 
410
+      : U8GLIB(&u8g_dev_st7920_192x32_4x_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, U8G_PIN_NONE, U8G_PIN_NONE, di, rw, reset)   // cs1 = cs2 = U8G_PIN_NONE
411
+      { }
412
+};
413
+
414
+
415
+class U8GLIB_ST7920_202X32 : public U8GLIB 
416
+{
417
+  public:
418
+    U8GLIB_ST7920_202X32(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
419
+      : U8GLIB(&u8g_dev_st7920_202x32_sw_spi, sck, mosi, cs, a0, reset)
420
+      { }
421
+    U8GLIB_ST7920_202X32(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
422
+      : U8GLIB(&u8g_dev_st7920_202x32_hw_spi, cs, a0, reset)
423
+      { }
424
+    U8GLIB_ST7920_202X32(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
425
+        uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) 
426
+      : U8GLIB(&u8g_dev_st7920_202x32_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset)
427
+      { }
428
+};
429
+
430
+class U8GLIB_ST7920_202X32_1X : public U8GLIB 
431
+{
432
+  public:
433
+    U8GLIB_ST7920_202X32_1X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t reset = U8G_PIN_NONE) 
434
+      : U8GLIB(&u8g_dev_st7920_202x32_sw_spi, sck, mosi, cs, U8G_PIN_NONE, reset)		// a0 = U8G_PIN_NONE
435
+      { }
436
+    U8GLIB_ST7920_202X32_1X(uint8_t cs, uint8_t reset = U8G_PIN_NONE) 
437
+      : U8GLIB(&u8g_dev_st7920_202x32_hw_spi, cs, U8G_PIN_NONE, reset)			// a0 = U8G_PIN_NONE
438
+      { }
439
+    U8GLIB_ST7920_202X32_1X(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
440
+        uint8_t en, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) 
441
+      : U8GLIB(&u8g_dev_st7920_202x32_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, U8G_PIN_NONE, U8G_PIN_NONE, di, rw, reset)  // cs1 = cs2 = U8G_PIN_NONE
442
+      { }
443
+};
444
+
445
+class U8GLIB_ST7920_202X32_4X : public U8GLIB 
446
+{
447
+  public:
448
+    U8GLIB_ST7920_202X32_4X(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t reset = U8G_PIN_NONE) 
449
+      : U8GLIB(&u8g_dev_st7920_202x32_4x_sw_spi, sck, mosi, cs, U8G_PIN_NONE, reset)		// a0 = U8G_PIN_NONE
450
+      { }
451
+    U8GLIB_ST7920_202X32_4X(uint8_t cs, uint8_t reset = U8G_PIN_NONE) 
452
+      : U8GLIB(&u8g_dev_st7920_202x32_4x_hw_spi, cs, U8G_PIN_NONE, reset)			// a0 = U8G_PIN_NONE
453
+      { }
454
+    U8GLIB_ST7920_202X32_4X(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
455
+        uint8_t en, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) 
456
+      : U8GLIB(&u8g_dev_st7920_202x32_4x_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, U8G_PIN_NONE, U8G_PIN_NONE, di, rw, reset)   // cs1 = cs2 = U8G_PIN_NONE
457
+      { }
458
+};
459
+
460
+
461
+class U8GLIB_LC7981_160X80 : public U8GLIB 
462
+{
463
+  public:
464
+    U8GLIB_LC7981_160X80(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
465
+        uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) 
466
+      : U8GLIB(&u8g_dev_lc7981_160x80_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, U8G_PIN_NONE, di, rw, reset)
467
+      { }
468
+};
469
+
470
+class U8GLIB_LC7981_240X64 : public U8GLIB 
471
+{
472
+  public:
473
+    U8GLIB_LC7981_240X64(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
474
+        uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) 
475
+      : U8GLIB(&u8g_dev_lc7981_240x64_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, U8G_PIN_NONE, di, rw, reset)
476
+      { }
477
+};
478
+
479
+class U8GLIB_LC7981_240X128 : public U8GLIB 
480
+{
481
+  public:
482
+    U8GLIB_LC7981_240X128(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
483
+        uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) 
484
+      : U8GLIB(&u8g_dev_lc7981_240x128_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, U8G_PIN_NONE, di, rw, reset)
485
+      { }
486
+};
487
+
488
+// 16 bit mode required: Remove comment from "#define U8G_16BIT 1" in utility/u8g.h
489
+class U8GLIB_LC7981_320X64 : public U8GLIB 
490
+{
491
+  public:
492
+    U8GLIB_LC7981_320X64(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
493
+        uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) 
494
+      : U8GLIB(&u8g_dev_lc7981_320x64_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, U8G_PIN_NONE, di, rw, reset)
495
+      { }
496
+};
497
+
498
+
499
+
500
+class U8GLIB_DOGXL160_BW : public U8GLIB 
501
+{
502
+  public:
503
+    U8GLIB_DOGXL160_BW(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
504
+      : U8GLIB(&u8g_dev_uc1610_dogxl160_bw_sw_spi, sck, mosi, cs, a0, reset)
505
+      { }
506
+    U8GLIB_DOGXL160_BW(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
507
+      : U8GLIB(&u8g_dev_uc1610_dogxl160_bw_hw_spi, cs, a0, reset)
508
+      { }
509
+};
510
+
511
+class U8GLIB_DOGXL160_GR : public U8GLIB 
512
+{
513
+  public:
514
+    U8GLIB_DOGXL160_GR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
515
+      : U8GLIB(&u8g_dev_uc1610_dogxl160_gr_sw_spi, sck, mosi, cs, a0, reset)
516
+      { }
517
+    U8GLIB_DOGXL160_GR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
518
+      : U8GLIB(&u8g_dev_uc1610_dogxl160_gr_hw_spi, cs, a0, reset)
519
+      { }
520
+};
521
+
522
+class U8GLIB_DOGXL160_2X_BW : public U8GLIB 
523
+{
524
+  public:
525
+    U8GLIB_DOGXL160_2X_BW(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
526
+      : U8GLIB(&u8g_dev_uc1610_dogxl160_2x_bw_sw_spi, sck, mosi, cs, a0, reset)
527
+      { }
528
+    U8GLIB_DOGXL160_2X_BW(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
529
+      : U8GLIB(&u8g_dev_uc1610_dogxl160_2x_bw_hw_spi, cs, a0, reset)
530
+      { }
531
+};
532
+
533
+class U8GLIB_DOGXL160_2X_GR : public U8GLIB 
534
+{
535
+  public:
536
+    U8GLIB_DOGXL160_2X_GR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
537
+      : U8GLIB(&u8g_dev_uc1610_dogxl160_2x_gr_sw_spi, sck, mosi, cs, a0, reset)
538
+      { }
539
+    U8GLIB_DOGXL160_2X_GR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
540
+      : U8GLIB(&u8g_dev_uc1610_dogxl160_2x_gr_hw_spi, cs, a0, reset)
541
+      { }
542
+};
543
+
544
+
545
+class U8GLIB_NHD27OLED_BW : public U8GLIB 
546
+{
547
+  public:
548
+    U8GLIB_NHD27OLED_BW(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
549
+      : U8GLIB(&u8g_dev_ssd1325_nhd27oled_bw_sw_spi, sck, mosi, cs, a0, reset)
550
+      { }
551
+    U8GLIB_NHD27OLED_BW(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
552
+      : U8GLIB(&u8g_dev_ssd1325_nhd27oled_bw_hw_spi, cs, a0, reset)
553
+      { }
554
+    U8GLIB_NHD27OLED_BW(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
555
+        uint8_t cs, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) 
556
+      : U8GLIB(&u8g_dev_ssd1325_nhd27oled_bw_parallel, d0, d1, d2, d3, d4, d5, d6, d7, U8G_PIN_NONE, cs, U8G_PIN_NONE, di, rw, reset)
557
+      { }
558
+};
559
+
560
+class U8GLIB_NHD27OLED_2X_BW : public U8GLIB 
561
+{
562
+  public:
563
+    U8GLIB_NHD27OLED_2X_BW(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
564
+      : U8GLIB(&u8g_dev_ssd1325_nhd27oled_2x_bw_sw_spi, sck, mosi, cs, a0, reset)
565
+      { }
566
+    U8GLIB_NHD27OLED_2X_BW(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
567
+      : U8GLIB(&u8g_dev_ssd1325_nhd27oled_2x_bw_hw_spi, cs, a0, reset)
568
+      { }
569
+    U8GLIB_NHD27OLED_2X_BW(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
570
+        uint8_t cs, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) 
571
+      : U8GLIB(&u8g_dev_ssd1325_nhd27oled_2x_bw_parallel, d0, d1, d2, d3, d4, d5, d6, d7, U8G_PIN_NONE, cs, U8G_PIN_NONE, di, rw, reset)
572
+      { }
573
+};
574
+
575
+class U8GLIB_NHD31OLED_BW : public U8GLIB 
576
+{
577
+  public:
578
+    U8GLIB_NHD31OLED_BW(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
579
+      : U8GLIB(&u8g_dev_ssd1322_nhd31oled_bw_sw_spi, sck, mosi, cs, a0, reset)
580
+      { }
581
+    U8GLIB_NHD31OLED_BW(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
582
+      : U8GLIB(&u8g_dev_ssd1322_nhd31oled_bw_hw_spi, cs, a0, reset)
583
+      { }
584
+};
585
+
586
+class U8GLIB_NHD31OLED_2X_BW : public U8GLIB 
587
+{
588
+  public:
589
+    U8GLIB_NHD31OLED_2X_BW(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
590
+      : U8GLIB(&u8g_dev_ssd1322_nhd31oled_2x_bw_sw_spi, sck, mosi, cs, a0, reset)
591
+      { }
592
+    U8GLIB_NHD31OLED_2X_BW(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
593
+      : U8GLIB(&u8g_dev_ssd1322_nhd31oled_2x_bw_hw_spi, cs, a0, reset)
594
+      { }
595
+};
596
+
597
+class U8GLIB_NHD31OLED_GR : public U8GLIB 
598
+{
599
+  public:
600
+    U8GLIB_NHD31OLED_GR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
601
+      : U8GLIB(&u8g_dev_ssd1322_nhd31oled_gr_sw_spi, sck, mosi, cs, a0, reset)
602
+      { }
603
+    U8GLIB_NHD31OLED_GR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
604
+      : U8GLIB(&u8g_dev_ssd1322_nhd31oled_gr_hw_spi, cs, a0, reset)
605
+      { }
606
+};
607
+
608
+class U8GLIB_NHD31OLED_2X_GR : public U8GLIB 
609
+{
610
+  public:
611
+    U8GLIB_NHD31OLED_2X_GR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
612
+      : U8GLIB(&u8g_dev_ssd1322_nhd31oled_2x_gr_sw_spi, sck, mosi, cs, a0, reset)
613
+      { }
614
+    U8GLIB_NHD31OLED_2X_GR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
615
+      : U8GLIB(&u8g_dev_ssd1322_nhd31oled_2x_gr_hw_spi, cs, a0, reset)
616
+      { }
617
+};
618
+
619
+
620
+class U8GLIB_SSD1306_128X64 : public U8GLIB 
621
+{
622
+  public:
623
+    U8GLIB_SSD1306_128X64(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
624
+      : U8GLIB(&u8g_dev_ssd1306_128x64_sw_spi, sck, mosi, cs, a0, reset)
625
+      { }
626
+    U8GLIB_SSD1306_128X64(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
627
+      : U8GLIB(&u8g_dev_ssd1306_128x64_hw_spi, cs, a0, reset)
628
+      { }
629
+    U8GLIB_SSD1306_128X64(uint8_t options = U8G_I2C_OPT_NONE) 
630
+      : U8GLIB(&u8g_dev_ssd1306_128x64_i2c, options)
631
+      { }
632
+      
633
+};
634
+
635
+class U8GLIB_SSD1309_128X64 : public U8GLIB 
636
+{
637
+  public:
638
+    U8GLIB_SSD1309_128X64(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
639
+      : U8GLIB(&u8g_dev_ssd1309_128x64_sw_spi, sck, mosi, cs, a0, reset)
640
+      { }
641
+    U8GLIB_SSD1309_128X64(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
642
+      : U8GLIB(&u8g_dev_ssd1309_128x64_hw_spi, cs, a0, reset)
643
+      { }
644
+    U8GLIB_SSD1309_128X64(uint8_t options = U8G_I2C_OPT_NONE) 
645
+      : U8GLIB(&u8g_dev_ssd1309_128x64_i2c, options)
646
+      { }
647
+      
648
+};
649
+
650
+class U8GLIB_SSD1306_128X32 : public U8GLIB 
651
+{
652
+  public:
653
+    U8GLIB_SSD1306_128X32(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
654
+      : U8GLIB(&u8g_dev_ssd1306_128x32_sw_spi, sck, mosi, cs, a0, reset)
655
+      { }
656
+    U8GLIB_SSD1306_128X32(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
657
+      : U8GLIB(&u8g_dev_ssd1306_128x32_hw_spi, cs, a0, reset)
658
+      { }
659
+    U8GLIB_SSD1306_128X32(uint8_t options = U8G_I2C_OPT_NONE) 
660
+      : U8GLIB(&u8g_dev_ssd1306_128x32_i2c, options)
661
+      { }
662
+      
663
+};
664
+
665
+
666
+class U8GLIB_NHD27OLED_GR : public U8GLIB 
667
+{
668
+  public:
669
+    U8GLIB_NHD27OLED_GR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
670
+      : U8GLIB(&u8g_dev_ssd1325_nhd27oled_gr_sw_spi, sck, mosi, cs, a0, reset)
671
+      { }
672
+    U8GLIB_NHD27OLED_GR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
673
+      : U8GLIB(&u8g_dev_ssd1325_nhd27oled_gr_hw_spi, cs, a0, reset)
674
+      { }
675
+};
676
+
677
+class U8GLIB_NHD27OLED_2X_GR : public U8GLIB 
678
+{
679
+  public:
680
+    U8GLIB_NHD27OLED_2X_GR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
681
+      : U8GLIB(&u8g_dev_ssd1325_nhd27oled_2x_gr_sw_spi, sck, mosi, cs, a0, reset)
682
+      { }
683
+    U8GLIB_NHD27OLED_2X_GR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
684
+      : U8GLIB(&u8g_dev_ssd1325_nhd27oled_2x_gr_hw_spi, cs, a0, reset)
685
+      { }
686
+};
687
+
688
+class U8GLIB_SSD1327_96X96_GR : public U8GLIB 
689
+{
690
+  public:
691
+    U8GLIB_SSD1327_96X96_GR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
692
+      : U8GLIB(&u8g_dev_ssd1327_96x96_gr_sw_spi, sck, mosi, cs, a0, reset)
693
+      { }
694
+    U8GLIB_SSD1327_96X96_GR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
695
+      : U8GLIB(&u8g_dev_ssd1327_96x96_gr_hw_spi, cs, a0, reset)
696
+      { }
697
+    U8GLIB_SSD1327_96X96_GR(uint8_t options = U8G_I2C_OPT_NONE) 
698
+      : U8GLIB(&u8g_dev_ssd1327_96x96_gr_i2c, options)
699
+      { }
700
+};
701
+
702
+class U8GLIB_SSD1327_96X96_2X_GR : public U8GLIB 
703
+{
704
+  public:
705
+    U8GLIB_SSD1327_96X96_2X_GR(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
706
+      : U8GLIB(&u8g_dev_ssd1327_96x96_2x_gr_sw_spi, sck, mosi, cs, a0, reset)
707
+      { }
708
+    U8GLIB_SSD1327_96X96_2X_GR(uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
709
+      : U8GLIB(&u8g_dev_ssd1327_96x96_2x_gr_hw_spi, cs, a0, reset)
710
+      { }
711
+    U8GLIB_SSD1327_96X96_2X_GR(uint8_t options = U8G_I2C_OPT_NONE) 
712
+      : U8GLIB(&u8g_dev_ssd1327_96x96_2x_gr_i2c, options)
713
+      { }
714
+};
715
+
716
+class U8GLIB_PCF8812 : public U8GLIB 
717
+{
718
+  public:
719
+    U8GLIB_PCF8812(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
720
+      : U8GLIB(&u8g_dev_pcf8812_96x65_sw_spi, sck, mosi, cs, a0, reset)
721
+      { }
722
+};
723
+
724
+class U8GLIB_PCD8544 : public U8GLIB 
725
+{
726
+  public:
727
+    U8GLIB_PCD8544(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
728
+      : U8GLIB(&u8g_dev_pcd8544_84x48_sw_spi, sck, mosi, cs, a0, reset)
729
+      { }
730
+};
731
+
732
+class U8GLIB_TLS8204_84X48 : public U8GLIB 
733
+{
734
+  public:
735
+    U8GLIB_TLS8204_84X48(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
736
+      : U8GLIB(&u8g_dev_tls8204_84x48_sw_spi, sck, mosi, cs, a0, reset)
737
+      { }
738
+};
739
+
740
+class U8GLIB_KS0108_128 : public U8GLIB 
741
+{
742
+  public:
743
+    U8GLIB_KS0108_128(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
744
+        uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) 
745
+      : U8GLIB(&u8g_dev_ks0108_128x64_fast, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset)
746
+      { }
747
+};
748
+
749
+class U8GLIB_SBN1661_122X32 : public U8GLIB 
750
+{
751
+  public:
752
+    U8GLIB_SBN1661_122X32(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
753
+        uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) 
754
+      : U8GLIB(&u8g_dev_sbn1661_122x32, d0, d1, d2, d3, d4, d5, d6, d7, U8G_PIN_NONE, cs1, cs2, di, rw, reset)
755
+      { }
756
+};
757
+
758
+class U8GLIB_T6963_240X128 : public U8GLIB 
759
+{
760
+  public:
761
+    U8GLIB_T6963_240X128(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
762
+        uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset = U8G_PIN_NONE) 
763
+      : U8GLIB(&u8g_dev_t6963_240x128_8bit, d0, d1, d2, d3, d4, d5, d6, d7, cs, a0, wr, rd, reset)
764
+      { }
765
+};
766
+
767
+class U8GLIB_T6963_240X64 : public U8GLIB 
768
+{
769
+  public:
770
+    U8GLIB_T6963_240X64(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
771
+        uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset = U8G_PIN_NONE) 
772
+      : U8GLIB(&u8g_dev_t6963_240x64_8bit, d0, d1, d2, d3, d4, d5, d6, d7, cs, a0, wr, rd, reset)
773
+      { }
774
+};
775
+
776
+class U8GLIB_T6963_128X64 : public U8GLIB 
777
+{
778
+  public:
779
+    U8GLIB_T6963_128X64(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
780
+        uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset = U8G_PIN_NONE) 
781
+      : U8GLIB(&u8g_dev_t6963_128x64_8bit, d0, d1, d2, d3, d4, d5, d6, d7, cs, a0, wr, rd, reset)
782
+      { }
783
+};
784
+
785
+
786
+class U8GLIB_ST7687_C144MVGD: public U8GLIB 
787
+{
788
+  public:
789
+    U8GLIB_ST7687_C144MVGD(uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset = U8G_PIN_NONE) 
790
+      : U8GLIB(&u8g_dev_st7687_c144mvgd_sw_spi, sck, mosi, cs, a0, reset)
791
+      { }
792
+    U8GLIB_ST7687_C144MVGD(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
793
+        uint8_t en, uint8_t cs, uint8_t a0, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) 
794
+      : U8GLIB(&u8g_dev_ks0108_128x64_fast, d0, d1, d2, d3, d4, d5, d6, d7, en, cs, U8G_PIN_NONE, a0, rw, reset)
795
+      { }
796
+};
797
+
798
+class U8GLIB_ILI9325D_320x240 : public U8GLIB 
799
+{
800
+  public:
801
+    /*
802
+    U8GLIB_ILI9325D_320x240(uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
803
+        uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) 
804
+      : U8GLIB(&u8g_dev_ili9325d_320x240_8bit, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, U8G_PIN_NONE, di, rw, reset)
805
+      { }
806
+  */
807
+    U8GLIB_ILI9325D_320x240( uint8_t en, uint8_t cs1, uint8_t di, uint8_t rw = U8G_PIN_NONE, uint8_t reset = U8G_PIN_NONE) 
808
+      { init8BitFixedPort(&u8g_dev_ili9325d_320x240_8bit, en, cs1, di, rw, reset); }
809
+};
810
+
811
+class U8GLIB_FLIPDISC_2X7 : public U8GLIB 
812
+{
813
+  public:
814
+    U8GLIB_FLIPDISC_2X7(void) : U8GLIB(&u8g_dev_flipdisc_2x7)
815
+      {  }
816
+};
817
+
818
+class U8GLIB_VS : public U8GLIB 
819
+{
820
+  public:
821
+    U8GLIB_VS(void) : U8GLIB(&u8g_dev_vs)
822
+      {  }
823
+};
824
+
825
+
826
+#endif /* _CPP_U8GLIB */

+ 130
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/Bitmap/Bitmap.pde View File

@@ -0,0 +1,130 @@
1
+/*
2
+
3
+  Bitmap.pde
4
+  
5
+  Show simple bitmap
6
+
7
+  >>> Before compiling: Please remove comment from the constructor of the 
8
+  >>> connected graphics display (see below).
9
+
10
+  Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
11
+  
12
+  Copyright (c) 2011, olikraus@gmail.com
13
+  All rights reserved.
14
+
15
+  Redistribution and use in source and binary forms, with or without modification, 
16
+  are permitted provided that the following conditions are met:
17
+
18
+  * Redistributions of source code must retain the above copyright notice, this list 
19
+    of conditions and the following disclaimer.
20
+    
21
+  * Redistributions in binary form must reproduce the above copyright notice, this 
22
+    list of conditions and the following disclaimer in the documentation and/or other 
23
+    materials provided with the distribution.
24
+
25
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
26
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
27
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
28
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
29
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
30
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
31
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
32
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
33
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
34
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
35
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
36
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
37
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
38
+  
39
+*/
40
+
41
+
42
+#include "U8glib.h"
43
+
44
+// setup u8g object, please remove comment from one of the following constructor calls
45
+// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
46
+
47
+//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
48
+//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
49
+//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
50
+//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
51
+//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
52
+//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
53
+//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
54
+//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
55
+//U8GLIB_DOGS102 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
56
+//U8GLIB_DOGM132 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
57
+//U8GLIB_DOGM128 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
58
+//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
59
+//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
60
+//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
61
+//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
62
+//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
63
+//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
64
+//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
65
+//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
66
+//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10);	// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
67
+//U8GLIB_ST7920_192X32_4X u8g(10);		// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
68
+//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
69
+//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
70
+//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
71
+//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
72
+//U8GLIB_LM6059 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
73
+//U8GLIB_LM6063 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
74
+//U8GLIB_DOGXL160_BW u8g(10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
75
+//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
76
+//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
77
+//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
78
+//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
79
+//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
80
+//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); 		// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
81
+//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
82
+//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
83
+//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
84
+//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 );  			// 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
85
+//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
86
+//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
87
+//U8GLIB_SSD1306_128X64 u8g(10, 9);		// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
88
+//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
89
+//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
90
+//U8GLIB_SSD1306_128X32 u8g(10, 9);             // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
91
+//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
92
+//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
93
+//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE);	// I2C
94
+//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE);	// I2C
95
+//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
96
+//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
97
+//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
98
+//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
99
+//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
100
+
101
+const uint8_t rook_bitmap[] PROGMEM = {
102
+  0x00,         // 00000000 
103
+  0x55,         // 01010101
104
+  0x7f,          // 01111111
105
+  0x3e,         // 00111110
106
+  0x3e,         // 00111110 
107
+  0x3e,         // 00111110
108
+  0x3e,         // 00111110 
109
+  0x7f           // 01111111
110
+};
111
+
112
+void draw(void) {
113
+  // graphic commands to redraw the complete screen should be placed here  
114
+  u8g.drawBitmapP( 0, 0, 1, 8, rook_bitmap);
115
+}
116
+
117
+void setup(void) {
118
+}
119
+
120
+void loop(void) {
121
+  // picture loop
122
+  u8g.firstPage();  
123
+  do {
124
+    draw();
125
+  } while( u8g.nextPage() );
126
+  
127
+  // rebuild the picture after some delay
128
+  delay(1000);
129
+}
130
+

+ 180
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/Chess/Chess.pde View File

@@ -0,0 +1,180 @@
1
+/*
2
+
3
+  Chess.pde
4
+  
5
+  Little Rook Chess
6
+
7
+  >>> Before compiling: Please remove comment from the constructor of the 
8
+  >>> connected graphics display (see below).
9
+  
10
+  Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
11
+  
12
+  Copyright (c) 2012, olikraus@gmail.com
13
+  All rights reserved.
14
+
15
+  Redistribution and use in source and binary forms, with or without modification, 
16
+  are permitted provided that the following conditions are met:
17
+
18
+  * Redistributions of source code must retain the above copyright notice, this list 
19
+    of conditions and the following disclaimer.
20
+    
21
+  * Redistributions in binary form must reproduce the above copyright notice, this 
22
+    list of conditions and the following disclaimer in the documentation and/or other 
23
+    materials provided with the distribution.
24
+
25
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
26
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
27
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
28
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
29
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
30
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
31
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
32
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
33
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
34
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
35
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
36
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
37
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
38
+  
39
+
40
+*/
41
+
42
+
43
+#include "U8glib.h"
44
+
45
+// setup u8g object, please remove comment from one of the following constructor calls
46
+// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
47
+
48
+//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
49
+//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
50
+//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
51
+//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
52
+//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
53
+//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
54
+//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
55
+//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
56
+//U8GLIB_DOGS102 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
57
+//U8GLIB_DOGM132 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
58
+//U8GLIB_DOGM128 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
59
+//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
60
+//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
61
+//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
62
+//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
63
+//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
64
+//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
65
+//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
66
+//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
67
+//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10);	// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
68
+//U8GLIB_ST7920_192X32_4X u8g(10);		// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
69
+//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
70
+//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
71
+//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
72
+//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
73
+//U8GLIB_LM6059 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
74
+//U8GLIB_LM6063 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
75
+//U8GLIB_DOGXL160_BW u8g(10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
76
+//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
77
+//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
78
+//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
79
+//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
80
+//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
81
+//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); 		// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
82
+//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
83
+//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
84
+//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
85
+//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 );  			// 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
86
+//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
87
+//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
88
+//U8GLIB_SSD1306_128X64 u8g(10, 9);		// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
89
+//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
90
+//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
91
+//U8GLIB_SSD1306_128X32 u8g(10, 9);             // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
92
+//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
93
+//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
94
+//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE);	// I2C
95
+//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE);	// I2C
96
+//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
97
+//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
98
+//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
99
+//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
100
+//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
101
+
102
+
103
+// DOGS102 shield configuration values
104
+uint8_t uiKeyPrev = 2;
105
+uint8_t uiKeyNext = 4;
106
+uint8_t uiKeySelect = 5;
107
+uint8_t uiKeyBack = 3;
108
+
109
+// DOGM128-Shield	 configuration values
110
+// DOGXL60-Shield configuration values
111
+//uint8_t uiKeyPrev = 7;
112
+//uint8_t uiKeyNext = 3;
113
+//uint8_t uiKeySelect = 2;
114
+//uint8_t uiKeyBack = 8;
115
+
116
+uint8_t uiKeyCodeFirst = CHESS_KEY_NONE;
117
+uint8_t uiKeyCodeSecond = CHESS_KEY_NONE;
118
+uint8_t uiKeyCode = CHESS_KEY_NONE;
119
+
120
+
121
+void uiSetup(void) {
122
+  // configure input keys 
123
+  
124
+  pinMode(uiKeyPrev, INPUT);           // set pin to input
125
+  digitalWrite(uiKeyPrev, HIGH);       // turn on pullup resistors
126
+  pinMode(uiKeyNext, INPUT);           // set pin to input
127
+  digitalWrite(uiKeyNext, HIGH);       // turn on pullup resistors
128
+  pinMode(uiKeySelect, INPUT);           // set pin to input
129
+  digitalWrite(uiKeySelect, HIGH);       // turn on pullup resistors
130
+  pinMode(uiKeyBack, INPUT);           // set pin to input
131
+  digitalWrite(uiKeyBack, HIGH);       // turn on pullup resistors
132
+}
133
+
134
+void uiStep(void)
135
+{
136
+  uiKeyCodeSecond = uiKeyCodeFirst;
137
+  if ( digitalRead(uiKeyPrev) == LOW )
138
+    uiKeyCodeFirst = CHESS_KEY_PREV;
139
+  else if ( digitalRead(uiKeyNext) == LOW )
140
+    uiKeyCodeFirst = CHESS_KEY_NEXT;
141
+  else if ( digitalRead(uiKeySelect) == LOW )
142
+    uiKeyCodeFirst = CHESS_KEY_SELECT;
143
+  else if ( digitalRead(uiKeyBack) == LOW )
144
+    uiKeyCodeFirst = CHESS_KEY_BACK;
145
+  else 
146
+    uiKeyCodeFirst = CHESS_KEY_NONE;
147
+  
148
+  if ( uiKeyCodeSecond == uiKeyCodeFirst )
149
+    uiKeyCode = uiKeyCodeFirst;
150
+  else
151
+    uiKeyCode = CHESS_KEY_NONE;
152
+}
153
+
154
+
155
+void setup() {
156
+  // rotate screen, if required
157
+  u8g.setRot180();
158
+  
159
+  uiSetup();
160
+  chess_Init(u8g.getU8g(), 0);
161
+}
162
+
163
+void loop() {  
164
+  uint8_t keyCode = CHESS_KEY_NONE;
165
+  
166
+  u8g.firstPage();
167
+  do {
168
+    chess_Draw();
169
+    uiStep();
170
+    if ( uiKeyCode != CHESS_KEY_NONE )
171
+      keyCode = uiKeyCode;
172
+  } while( u8g.nextPage() );
173
+  
174
+  u8g_Delay(10);
175
+  chess_Step(keyCode);
176
+  uiStep();
177
+  keyCode = uiKeyCode;
178
+}
179
+
180
+

+ 230
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/Console/Console.pde View File

@@ -0,0 +1,230 @@
1
+/*
2
+
3
+  Console.pde
4
+  
5
+  Read from serial monitor, output to display
6
+  
7
+  >>> Before compiling: Please remove comment from the constructor of the 
8
+  >>> connected graphics display (see below).
9
+  
10
+  Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
11
+  
12
+  Copyright (c) 2011, olikraus@gmail.com
13
+  All rights reserved.
14
+
15
+  Redistribution and use in source and binary forms, with or without modification, 
16
+  are permitted provided that the following conditions are met:
17
+
18
+  * Redistributions of source code must retain the above copyright notice, this list 
19
+    of conditions and the following disclaimer.
20
+    
21
+  * Redistributions in binary form must reproduce the above copyright notice, this 
22
+    list of conditions and the following disclaimer in the documentation and/or other 
23
+    materials provided with the distribution.
24
+
25
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
26
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
27
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
28
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
29
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
30
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
31
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
32
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
33
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
34
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
35
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
36
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
37
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
38
+  
39
+*/
40
+
41
+
42
+#include "U8glib.h"
43
+
44
+// setup u8g object, please remove comment from one of the following constructor calls
45
+// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
46
+
47
+//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
48
+//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
49
+//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
50
+//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
51
+//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
52
+//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
53
+//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
54
+//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
55
+//U8GLIB_DOGS102 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
56
+//U8GLIB_DOGM132 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
57
+//U8GLIB_DOGM128 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
58
+//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
59
+//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
60
+//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
61
+//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
62
+//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
63
+//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
64
+//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
65
+//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
66
+//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10);	// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
67
+//U8GLIB_ST7920_192X32_4X u8g(10);		// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
68
+//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
69
+//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
70
+//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
71
+//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
72
+//U8GLIB_LM6059 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
73
+//U8GLIB_LM6063 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
74
+//U8GLIB_DOGXL160_BW u8g(10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
75
+//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
76
+//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
77
+//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
78
+//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
79
+//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
80
+//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); 		// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
81
+//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
82
+//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
83
+//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
84
+//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 );  			// 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
85
+//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
86
+//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
87
+//U8GLIB_SSD1306_128X64 u8g(10, 9);		// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
88
+//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
89
+//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
90
+//U8GLIB_SSD1306_128X32 u8g(10, 9);             // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
91
+//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
92
+//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
93
+//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE);	// I2C
94
+//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE);	// I2C
95
+//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
96
+//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
97
+//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
98
+//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
99
+//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
100
+
101
+
102
+// setup input buffer
103
+#define LINE_MAX 30 
104
+uint8_t line_buf[LINE_MAX] = "U8GLIB Console";
105
+uint8_t line_pos = 0;
106
+
107
+// setup a text screen to support scrolling
108
+#define ROW_MAX 12
109
+
110
+
111
+uint8_t screen[ROW_MAX][LINE_MAX];
112
+uint8_t rows, cols;
113
+
114
+// line height, which matches the selected font (5x7)
115
+#define LINE_PIXEL_HEIGHT 7
116
+
117
+// clear entire screen, called during setup
118
+void clear_screen(void) {
119
+  uint8_t i, j;
120
+  for( i = 0; i < ROW_MAX; i++ )
121
+    for( j = 0; j < LINE_MAX; j++ )
122
+      screen[i][j] = 0;  
123
+}
124
+
125
+// append a line to the screen, scroll up
126
+void add_line_to_screen(void) {
127
+  uint8_t i, j;
128
+  for( j = 0; j < LINE_MAX; j++ )
129
+    for( i = 0; i < rows-1; i++ )
130
+      screen[i][j] = screen[i+1][j];
131
+  
132
+  for( j = 0; j < LINE_MAX; j++ )
133
+    screen[rows-1][j] = line_buf[j];
134
+}
135
+
136
+// U8GLIB draw procedure: output the screen
137
+void draw(void) {
138
+  uint8_t i, y;
139
+  // graphic commands to redraw the complete screen are placed here    
140
+  y = 0;       // reference is the top left -1 position of the string
141
+  y--;           // correct the -1 position of the drawStr 
142
+  for( i = 0; i < rows; i++ )
143
+  {
144
+    u8g.drawStr( 0, y, (char *)(screen[i]));
145
+    y += u8g.getFontLineSpacing();
146
+  }
147
+}
148
+
149
+void exec_line(void) {
150
+  // echo line to the serial monitor
151
+  Serial.println((const char *)line_buf);
152
+  
153
+  // add the line to the screen
154
+  add_line_to_screen();
155
+  
156
+  // U8GLIB picture loop
157
+  u8g.firstPage();  
158
+  do {
159
+    draw();
160
+  } while( u8g.nextPage() );
161
+}
162
+
163
+// clear current input buffer
164
+void reset_line(void) { 
165
+      line_pos = 0;
166
+      line_buf[line_pos] = '\0';  
167
+}
168
+
169
+// add a single character to the input buffer 
170
+void char_to_line(uint8_t c) {
171
+      line_buf[line_pos] = c;
172
+      line_pos++;
173
+      line_buf[line_pos] = '\0';  
174
+}
175
+
176
+// check serial in and handle the character
177
+void read_line(void) {
178
+  if ( Serial.available() )
179
+  {
180
+    uint8_t c;
181
+    c = Serial.read();
182
+    if ( line_pos >= cols-1 ) {
183
+      exec_line();
184
+      reset_line();
185
+      char_to_line(c);
186
+    } 
187
+    else if ( c == '\n' ) {
188
+      // ignore '\n' 
189
+    }
190
+    else if ( c == '\r' ) {
191
+      exec_line();
192
+      reset_line();
193
+    }
194
+    else {
195
+      char_to_line(c);
196
+    }
197
+  }
198
+}
199
+
200
+// Arduino master setup
201
+void setup(void) {
202
+  // set font for the console window
203
+  u8g.setFont(u8g_font_5x7);
204
+  //u8g.setFont(u8g_font_9x15);
205
+  
206
+  // set upper left position for the string draw procedure
207
+  u8g.setFontPosTop();
208
+  
209
+  // calculate the number of rows for the display
210
+  rows = u8g.getHeight() / u8g.getFontLineSpacing();
211
+  if ( rows > ROW_MAX )
212
+    rows = ROW_MAX; 
213
+  
214
+  // estimate the number of columns for the display
215
+  cols = u8g.getWidth() / u8g.getStrWidth("m");
216
+  if ( cols > LINE_MAX-1 )
217
+    cols = LINE_MAX-1; 
218
+  
219
+  clear_screen();               // clear screen
220
+  delay(1000);                  // do some delay
221
+  Serial.begin(9600);        // init serial
222
+  exec_line();                    // place the input buffer into the screen
223
+  reset_line();                   // clear input buffer
224
+}
225
+
226
+// Arduino main loop
227
+void loop(void) {
228
+  read_line();
229
+}
230
+

+ 139
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/F/F.pde View File

@@ -0,0 +1,139 @@
1
+/*
2
+
3
+  F.pde
4
+  
5
+  Example code for the F() macro.
6
+  
7
+  >>> This example requires Arduino 1.0 and above.
8
+  
9
+  >>> Before compiling: Please remove comment from the constructor of the 
10
+  >>> connected graphics display (see below).
11
+  
12
+  Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
13
+  
14
+  Copyright (c) 2012, olikraus@gmail.com
15
+  All rights reserved.
16
+
17
+  Redistribution and use in source and binary forms, with or without modification, 
18
+  are permitted provided that the following conditions are met:
19
+
20
+  * Redistributions of source code must retain the above copyright notice, this list 
21
+    of conditions and the following disclaimer.
22
+    
23
+  * Redistributions in binary form must reproduce the above copyright notice, this 
24
+    list of conditions and the following disclaimer in the documentation and/or other 
25
+    materials provided with the distribution.
26
+
27
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
28
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
29
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
30
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
31
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
32
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
33
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
34
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
35
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
36
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
37
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
38
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
39
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
40
+  
41
+*/
42
+
43
+
44
+#include "U8glib.h"
45
+
46
+// setup u8g object, please remove comment from one of the following constructor calls
47
+// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
48
+
49
+//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
50
+//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
51
+//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
52
+//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
53
+//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
54
+//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
55
+//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
56
+//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
57
+//U8GLIB_DOGS102 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
58
+//U8GLIB_DOGM132 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
59
+//U8GLIB_DOGM128 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
60
+//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
61
+//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
62
+//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
63
+//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
64
+//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
65
+//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
66
+//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
67
+//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
68
+//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10);	// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
69
+//U8GLIB_ST7920_192X32_4X u8g(10);		// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
70
+//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
71
+//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
72
+//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
73
+//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
74
+//U8GLIB_LM6059 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
75
+//U8GLIB_LM6063 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
76
+//U8GLIB_DOGXL160_BW u8g(10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
77
+//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
78
+//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
79
+//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
80
+//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
81
+//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
82
+//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); 		// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
83
+//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
84
+//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
85
+//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
86
+//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 );  			// 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
87
+//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
88
+//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
89
+//U8GLIB_SSD1306_128X64 u8g(10, 9);		// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
90
+//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
91
+//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
92
+//U8GLIB_SSD1306_128X32 u8g(10, 9);             // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
93
+//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
94
+//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
95
+//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE);	// I2C
96
+//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE);	// I2C
97
+//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
98
+//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
99
+//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
100
+//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
101
+//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
102
+
103
+void draw(void) {
104
+  // graphic commands to redraw the complete screen should be placed here  
105
+  
106
+  // assign default font
107
+  u8g.setFont(u8g_font_unifont);
108
+  
109
+  // pointer to strings in flash memory can be stored in a special type
110
+  const __FlashStringHelper *flash_ptr;
111
+  
112
+  // the result of the F() macro can be assigned to this pointer
113
+  flash_ptr = F("Hello World!");
114
+  
115
+  // this pointer can be used as argument to the draw procedures
116
+  u8g.drawStr( 0+1, 20+1, flash_ptr);
117
+  u8g.drawStr( 0, 20, flash_ptr);
118
+  
119
+  // of course, the F() macro can be used directly
120
+  u8g.drawStr( 0, 40, F("PROGMEM"));
121
+
122
+}
123
+
124
+void setup(void) {
125
+  // flip screen, if required
126
+  // u8g.setRot180();
127
+}
128
+
129
+void loop(void) {
130
+  // picture loop
131
+  u8g.firstPage();  
132
+  do {
133
+    draw();
134
+  } while( u8g.nextPage() );
135
+  
136
+  // rebuild the picture after some delay
137
+  delay(500);
138
+}
139
+

+ 223
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/GraphicsTest/GraphicsTest.pde View File

@@ -0,0 +1,223 @@
1
+/*
2
+
3
+  GraphicsTest.pde
4
+  
5
+  >>> Before compiling: Please remove comment from the constructor of the 
6
+  >>> connected graphics display (see below).
7
+  
8
+  Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
9
+  
10
+  Copyright (c) 2012, olikraus@gmail.com
11
+  All rights reserved.
12
+
13
+  Redistribution and use in source and binary forms, with or without modification, 
14
+  are permitted provided that the following conditions are met:
15
+
16
+  * Redistributions of source code must retain the above copyright notice, this list 
17
+    of conditions and the following disclaimer.
18
+    
19
+  * Redistributions in binary form must reproduce the above copyright notice, this 
20
+    list of conditions and the following disclaimer in the documentation and/or other 
21
+    materials provided with the distribution.
22
+
23
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
24
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
25
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
26
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
27
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
28
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
29
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
30
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
31
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
32
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
33
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
34
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
35
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
36
+
37
+
38
+*/
39
+
40
+
41
+#include "U8glib.h"
42
+
43
+// setup u8g object, please remove comment from one of the following constructor calls
44
+// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
45
+
46
+//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
47
+//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
48
+//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
49
+//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
50
+//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
51
+//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
52
+//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
53
+//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
54
+//U8GLIB_DOGS102 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
55
+//U8GLIB_DOGM132 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
56
+//U8GLIB_DOGM128 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
57
+//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
58
+//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
59
+//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
60
+//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
61
+//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
62
+//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
63
+//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
64
+//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
65
+//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10);	// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
66
+//U8GLIB_ST7920_192X32_4X u8g(10);		// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
67
+//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
68
+//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
69
+//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
70
+//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
71
+//U8GLIB_LM6059 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
72
+//U8GLIB_LM6063 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
73
+//U8GLIB_DOGXL160_BW u8g(10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
74
+//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
75
+//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
76
+//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
77
+//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
78
+//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
79
+//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); 		// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
80
+//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
81
+//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
82
+//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
83
+//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 );  			// 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
84
+//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
85
+//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
86
+//U8GLIB_SSD1306_128X64 u8g(10, 9);		// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
87
+//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
88
+//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
89
+//U8GLIB_SSD1306_128X32 u8g(10, 9);             // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
90
+//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
91
+//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
92
+//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE);	// I2C
93
+//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE);	// I2C
94
+//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
95
+//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
96
+//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
97
+//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
98
+//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
99
+
100
+void u8g_prepare(void) {
101
+  u8g.setFont(u8g_font_6x10);
102
+  u8g.setFontRefHeightExtendedText();
103
+  u8g.setDefaultForegroundColor();
104
+  u8g.setFontPosTop();
105
+}
106
+
107
+void u8g_box_frame(uint8_t a) {
108
+  u8g.drawStr( 0, 0, "drawBox");
109
+  u8g.drawBox(5,10,20,10);
110
+  u8g.drawBox(10+a,15,30,7);
111
+  u8g.drawStr( 0, 30, "drawFrame");
112
+  u8g.drawFrame(5,10+30,20,10);
113
+  u8g.drawFrame(10+a,15+30,30,7);
114
+}
115
+
116
+void u8g_disc_circle(uint8_t a) {
117
+  u8g.drawStr( 0, 0, "drawDisc");
118
+  u8g.drawDisc(10,18,9);
119
+  u8g.drawDisc(24+a,16,7);
120
+  u8g.drawStr( 0, 30, "drawCircle");
121
+  u8g.drawCircle(10,18+30,9);
122
+  u8g.drawCircle(24+a,16+30,7);
123
+}
124
+
125
+void u8g_r_frame(uint8_t a) {
126
+  u8g.drawStr( 0, 0, "drawRFrame/Box");
127
+  u8g.drawRFrame(5, 10,40,30, a+1);
128
+  u8g.drawRBox(50, 10,25,40, a+1);
129
+}
130
+
131
+void u8g_string(uint8_t a) {
132
+  u8g.drawStr(30+a,31, " 0");
133
+  u8g.drawStr90(30,31+a, " 90");
134
+  u8g.drawStr180(30-a,31, " 180");
135
+  u8g.drawStr270(30,31-a, " 270");
136
+}
137
+
138
+void u8g_line(uint8_t a) {
139
+  u8g.drawStr( 0, 0, "drawLine");
140
+  u8g.drawLine(7+a, 10, 40, 55);
141
+  u8g.drawLine(7+a*2, 10, 60, 55);
142
+  u8g.drawLine(7+a*3, 10, 80, 55);
143
+  u8g.drawLine(7+a*4, 10, 100, 55);
144
+}
145
+
146
+void u8g_ascii_1() {
147
+  char s[2] = " ";
148
+  uint8_t x, y;
149
+  u8g.drawStr( 0, 0, "ASCII page 1");
150
+  for( y = 0; y < 6; y++ ) {
151
+    for( x = 0; x < 16; x++ ) {
152
+      s[0] = y*16 + x + 32;
153
+      u8g.drawStr(x*7, y*10+10, s);
154
+    }
155
+  }
156
+}
157
+
158
+void u8g_ascii_2() {
159
+  char s[2] = " ";
160
+  uint8_t x, y;
161
+  u8g.drawStr( 0, 0, "ASCII page 2");
162
+  for( y = 0; y < 6; y++ ) {
163
+    for( x = 0; x < 16; x++ ) {
164
+      s[0] = y*16 + x + 160;
165
+      u8g.drawStr(x*7, y*10+10, s);
166
+    }
167
+  }
168
+}
169
+
170
+
171
+uint8_t draw_state = 0;
172
+
173
+void draw(void) {
174
+  u8g_prepare();
175
+  switch(draw_state >> 3) {
176
+    case 0: u8g_box_frame(draw_state&7); break;
177
+    case 1: u8g_disc_circle(draw_state&7); break;
178
+    case 2: u8g_r_frame(draw_state&7); break;
179
+    case 3: u8g_string(draw_state&7); break;
180
+    case 4: u8g_line(draw_state&7); break;
181
+    case 5: u8g_ascii_1(); break;
182
+    case 6: u8g_ascii_2(); break;
183
+  }
184
+}
185
+
186
+void setup(void) {
187
+
188
+  // flip screen, if required
189
+  //u8g.setRot180();
190
+
191
+  // assign default color value
192
+  if ( u8g.getMode() == U8G_MODE_R3G3B2 ) 
193
+    u8g.setColorIndex(255);     // white
194
+  else if ( u8g.getMode() == U8G_MODE_GRAY2BIT )
195
+    u8g.setColorIndex(3);         // max intensity
196
+  else if ( u8g.getMode() == U8G_MODE_BW )
197
+    u8g.setColorIndex(1);         // pixel on
198
+  
199
+  //u8g.setContrast(0x30);
200
+  
201
+  pinMode(13, OUTPUT);           
202
+  digitalWrite(13, HIGH);  
203
+}
204
+
205
+void loop(void) {
206
+  
207
+  // picture loop  
208
+  u8g.firstPage();  
209
+  do {
210
+    draw();
211
+  } while( u8g.nextPage() );
212
+  
213
+  // increase the state
214
+  draw_state++;
215
+  if ( draw_state >= 7*8 )
216
+    draw_state = 0;
217
+  
218
+  // rebuild the picture after some delay
219
+  delay(150);
220
+
221
+}
222
+
223
+

+ 136
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/HelloWorld/HelloWorld.pde View File

@@ -0,0 +1,136 @@
1
+/*
2
+
3
+  HelloWorld.pde
4
+  
5
+  "Hello World!" example code.
6
+  
7
+  >>> Before compiling: Please remove comment from the constructor of the 
8
+  >>> connected graphics display (see below).
9
+  
10
+  Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
11
+  
12
+  Copyright (c) 2012, olikraus@gmail.com
13
+  All rights reserved.
14
+
15
+  Redistribution and use in source and binary forms, with or without modification, 
16
+  are permitted provided that the following conditions are met:
17
+
18
+  * Redistributions of source code must retain the above copyright notice, this list 
19
+    of conditions and the following disclaimer.
20
+    
21
+  * Redistributions in binary form must reproduce the above copyright notice, this 
22
+    list of conditions and the following disclaimer in the documentation and/or other 
23
+    materials provided with the distribution.
24
+
25
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
26
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
27
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
28
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
29
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
30
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
31
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
32
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
33
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
34
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
35
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
36
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
37
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
38
+  
39
+*/
40
+
41
+
42
+#include "U8glib.h"
43
+
44
+// setup u8g object, please remove comment from one of the following constructor calls
45
+// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
46
+
47
+//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
48
+//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
49
+//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
50
+//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
51
+//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
52
+//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
53
+//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
54
+//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
55
+//U8GLIB_DOGS102 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
56
+//U8GLIB_DOGM132 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
57
+//U8GLIB_DOGM128 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
58
+//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
59
+//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
60
+//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
61
+//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
62
+//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
63
+//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
64
+//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
65
+//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
66
+//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10);	// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
67
+//U8GLIB_ST7920_192X32_4X u8g(10);		// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
68
+//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
69
+//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
70
+//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
71
+//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
72
+//U8GLIB_LM6059 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
73
+//U8GLIB_LM6063 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
74
+//U8GLIB_DOGXL160_BW u8g(10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
75
+//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
76
+//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
77
+//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
78
+//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
79
+//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
80
+//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); 		// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
81
+//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
82
+//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
83
+//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
84
+//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 );  			// 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
85
+//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
86
+//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
87
+//U8GLIB_SSD1306_128X64 u8g(10, 9);		// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
88
+//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
89
+//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
90
+//U8GLIB_SSD1306_128X32 u8g(10, 9);             // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
91
+//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
92
+//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
93
+//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE);	// I2C
94
+//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE);	// I2C
95
+//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
96
+//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
97
+//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
98
+//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
99
+//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
100
+
101
+
102
+void draw(void) {
103
+  // graphic commands to redraw the complete screen should be placed here  
104
+  u8g.setFont(u8g_font_unifont);
105
+  //u8g.setFont(u8g_font_osb21);
106
+  u8g.drawStr( 0, 22, "Hello World!");
107
+}
108
+
109
+void setup(void) {
110
+  
111
+  // flip screen, if required
112
+  // u8g.setRot180();
113
+  
114
+  // set SPI backup if required
115
+  //u8g.setHardwareBackup(u8g_backup_avr_spi);
116
+
117
+  // assign default color value
118
+  if ( u8g.getMode() == U8G_MODE_R3G3B2 ) 
119
+    u8g.setColorIndex(255);     // white
120
+  else if ( u8g.getMode() == U8G_MODE_GRAY2BIT )
121
+    u8g.setColorIndex(3);         // max intensity
122
+  else if ( u8g.getMode() == U8G_MODE_BW )
123
+    u8g.setColorIndex(1);         // pixel on
124
+}
125
+
126
+void loop(void) {
127
+  // picture loop
128
+  u8g.firstPage();  
129
+  do {
130
+    draw();
131
+  } while( u8g.nextPage() );
132
+  
133
+  // rebuild the picture after some delay
134
+  delay(500);
135
+}
136
+

+ 234
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/Menu/Menu.pde View File

@@ -0,0 +1,234 @@
1
+/*
2
+
3
+  Menu.pde
4
+  
5
+  Simple Menu Selection
6
+
7
+  >>> Before compiling: Please remove comment from the constructor of the 
8
+  >>> connected graphics display (see below).
9
+  
10
+  Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
11
+  
12
+  Copyright (c) 2012, olikraus@gmail.com
13
+  All rights reserved.
14
+
15
+  Redistribution and use in source and binary forms, with or without modification, 
16
+  are permitted provided that the following conditions are met:
17
+
18
+  * Redistributions of source code must retain the above copyright notice, this list 
19
+    of conditions and the following disclaimer.
20
+    
21
+  * Redistributions in binary form must reproduce the above copyright notice, this 
22
+    list of conditions and the following disclaimer in the documentation and/or other 
23
+    materials provided with the distribution.
24
+
25
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
26
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
27
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
28
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
29
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
30
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
31
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
32
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
33
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
34
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
35
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
36
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
37
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
38
+  
39
+
40
+*/
41
+
42
+
43
+#include "U8glib.h"
44
+
45
+// setup u8g object, please remove comment from one of the following constructor calls
46
+// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
47
+
48
+//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
49
+//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
50
+//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
51
+//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
52
+//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
53
+//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
54
+//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
55
+//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
56
+//U8GLIB_DOGS102 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
57
+//U8GLIB_DOGM132 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
58
+//U8GLIB_DOGM128 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
59
+//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
60
+//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
61
+//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
62
+//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
63
+//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
64
+//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
65
+//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
66
+//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
67
+//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10);	// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
68
+//U8GLIB_ST7920_192X32_4X u8g(10);		// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
69
+//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
70
+//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
71
+//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
72
+//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
73
+//U8GLIB_LM6059 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
74
+//U8GLIB_LM6063 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
75
+//U8GLIB_DOGXL160_BW u8g(10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
76
+//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
77
+//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
78
+//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
79
+//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
80
+//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
81
+//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); 		// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
82
+//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
83
+//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
84
+//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
85
+//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 );  			// 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
86
+//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
87
+//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
88
+//U8GLIB_SSD1306_128X64 u8g(10, 9);		// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
89
+//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
90
+//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
91
+//U8GLIB_SSD1306_128X32 u8g(10, 9);             // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
92
+//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
93
+//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
94
+//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE);	// I2C
95
+//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE);	// I2C
96
+//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
97
+//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
98
+//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
99
+//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
100
+//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
101
+
102
+
103
+#define KEY_NONE 0
104
+#define KEY_PREV 1
105
+#define KEY_NEXT 2
106
+#define KEY_SELECT 3
107
+#define KEY_BACK 4
108
+
109
+// DOGS102 shield configuration values
110
+//uint8_t uiKeyPrev = 2;
111
+//uint8_t uiKeyNext = 4;
112
+//uint8_t uiKeySelect = 5;
113
+//uint8_t uiKeyBack = 3;
114
+
115
+// DOGM128-Shield	 configuration values
116
+// DOGXL60-Shield configuration values
117
+uint8_t uiKeyPrev = 7;
118
+uint8_t uiKeyNext = 3;
119
+uint8_t uiKeySelect = 2;
120
+uint8_t uiKeyBack = 8;
121
+
122
+uint8_t uiKeyCodeFirst = KEY_NONE;
123
+uint8_t uiKeyCodeSecond = KEY_NONE;
124
+uint8_t uiKeyCode = KEY_NONE;
125
+
126
+
127
+void uiSetup(void) {
128
+  // configure input keys 
129
+  
130
+  pinMode(uiKeyPrev, INPUT);           // set pin to input
131
+  digitalWrite(uiKeyPrev, HIGH);       // turn on pullup resistors
132
+  pinMode(uiKeyNext, INPUT);           // set pin to input
133
+  digitalWrite(uiKeyNext, HIGH);       // turn on pullup resistors
134
+  pinMode(uiKeySelect, INPUT);           // set pin to input
135
+  digitalWrite(uiKeySelect, HIGH);       // turn on pullup resistors
136
+  pinMode(uiKeyBack, INPUT);           // set pin to input
137
+  digitalWrite(uiKeyBack, HIGH);       // turn on pullup resistors
138
+}
139
+
140
+void uiStep(void) {
141
+  uiKeyCodeSecond = uiKeyCodeFirst;
142
+  if ( digitalRead(uiKeyPrev) == LOW )
143
+    uiKeyCodeFirst = KEY_PREV;
144
+  else if ( digitalRead(uiKeyNext) == LOW )
145
+    uiKeyCodeFirst = KEY_NEXT;
146
+  else if ( digitalRead(uiKeySelect) == LOW )
147
+    uiKeyCodeFirst = KEY_SELECT;
148
+  else if ( digitalRead(uiKeyBack) == LOW )
149
+    uiKeyCodeFirst = KEY_BACK;
150
+  else 
151
+    uiKeyCodeFirst = KEY_NONE;
152
+  
153
+  if ( uiKeyCodeSecond == uiKeyCodeFirst )
154
+    uiKeyCode = uiKeyCodeFirst;
155
+  else
156
+    uiKeyCode = KEY_NONE;
157
+}
158
+
159
+
160
+#define MENU_ITEMS 4
161
+char *menu_strings[MENU_ITEMS] = { "First Line", "Second Item", "3333333", "abcdefg" };
162
+
163
+uint8_t menu_current = 0;
164
+uint8_t menu_redraw_required = 0;
165
+uint8_t last_key_code = KEY_NONE;
166
+
167
+
168
+void drawMenu(void) {
169
+  uint8_t i, h;
170
+  u8g_uint_t w, d;
171
+
172
+  u8g.setFont(u8g_font_6x13);
173
+  u8g.setFontRefHeightText();
174
+  u8g.setFontPosTop();
175
+  
176
+  h = u8g.getFontAscent()-u8g.getFontDescent();
177
+  w = u8g.getWidth();
178
+  for( i = 0; i < MENU_ITEMS; i++ ) {
179
+    d = (w-u8g.getStrWidth(menu_strings[i]))/2;
180
+    u8g.setDefaultForegroundColor();
181
+    if ( i == menu_current ) {
182
+      u8g.drawBox(0, i*h+1, w, h);
183
+      u8g.setDefaultBackgroundColor();
184
+    }
185
+    u8g.drawStr(d, i*h, menu_strings[i]);
186
+  }
187
+}
188
+
189
+void updateMenu(void) {
190
+  if ( uiKeyCode != KEY_NONE && last_key_code == uiKeyCode ) {
191
+    return;
192
+  }
193
+  last_key_code = uiKeyCode;
194
+  
195
+  switch ( uiKeyCode ) {
196
+    case KEY_NEXT:
197
+      menu_current++;
198
+      if ( menu_current >= MENU_ITEMS )
199
+        menu_current = 0;
200
+      menu_redraw_required = 1;
201
+      break;
202
+    case KEY_PREV:
203
+      if ( menu_current == 0 )
204
+        menu_current = MENU_ITEMS;
205
+      menu_current--;
206
+      menu_redraw_required = 1;
207
+      break;
208
+  }
209
+}
210
+
211
+
212
+void setup() {
213
+  // rotate screen, if required
214
+  // u8g.setRot180();
215
+  
216
+  uiSetup();                                // setup key detection and debounce algorithm
217
+  menu_redraw_required = 1;     // force initial redraw
218
+}
219
+
220
+void loop() {  
221
+
222
+  uiStep();                                     // check for key press
223
+    
224
+  if (  menu_redraw_required != 0 ) {
225
+    u8g.firstPage();
226
+    do  {
227
+      drawMenu();
228
+    } while( u8g.nextPage() );
229
+    menu_redraw_required = 0;
230
+  }
231
+
232
+  updateMenu();                            // update menu bar
233
+  
234
+}

+ 124
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/PrintTest/PrintTest.pde View File

@@ -0,0 +1,124 @@
1
+/*
2
+
3
+  PrintTest.pde
4
+  
5
+  How to use the base class "Print"
6
+  
7
+  >>> Before compiling: Please remove comment from the constructor of the 
8
+  >>> connected graphics display (see below).
9
+  
10
+  Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
11
+  
12
+  Copyright (c) 2012, olikraus@gmail.com
13
+  All rights reserved.
14
+
15
+  Redistribution and use in source and binary forms, with or without modification, 
16
+  are permitted provided that the following conditions are met:
17
+
18
+  * Redistributions of source code must retain the above copyright notice, this list 
19
+    of conditions and the following disclaimer.
20
+    
21
+  * Redistributions in binary form must reproduce the above copyright notice, this 
22
+    list of conditions and the following disclaimer in the documentation and/or other 
23
+    materials provided with the distribution.
24
+
25
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
26
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
27
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
28
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
29
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
30
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
31
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
32
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
33
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
34
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
35
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
36
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
37
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
38
+  
39
+*/
40
+
41
+
42
+#include "U8glib.h"
43
+
44
+// setup u8g object, please remove comment from one of the following constructor calls
45
+// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
46
+
47
+//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
48
+//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
49
+//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
50
+//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
51
+//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
52
+//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
53
+//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
54
+//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
55
+//U8GLIB_DOGS102 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
56
+//U8GLIB_DOGM132 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
57
+//U8GLIB_DOGM128 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
58
+//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
59
+//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
60
+//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
61
+//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
62
+//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
63
+//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
64
+//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
65
+//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
66
+//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10);	// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
67
+//U8GLIB_ST7920_192X32_4X u8g(10);		// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
68
+//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
69
+//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
70
+//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
71
+//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
72
+//U8GLIB_LM6059 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
73
+//U8GLIB_LM6063 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
74
+//U8GLIB_DOGXL160_BW u8g(10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
75
+//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
76
+//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
77
+//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
78
+//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
79
+//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
80
+//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); 		// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
81
+//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
82
+//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
83
+//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
84
+//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 );  			// 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
85
+//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
86
+//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
87
+//U8GLIB_SSD1306_128X64 u8g(10, 9);		// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
88
+//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
89
+//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
90
+//U8GLIB_SSD1306_128X32 u8g(10, 9);             // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
91
+//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
92
+//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
93
+//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE);	// I2C
94
+//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE);	// I2C
95
+//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
96
+//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
97
+//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
98
+//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
99
+//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
100
+
101
+void draw(void) {
102
+  // graphic commands to redraw the complete screen should be placed here  
103
+  u8g.setFont(u8g_font_unifont);
104
+  u8g.setPrintPos(0, 20); 
105
+  // call procedure from base class, http://arduino.cc/en/Serial/Print
106
+  u8g.print("Hello World!");
107
+}
108
+
109
+void setup(void) {
110
+  // flip screen, if required
111
+  // u8g.setRot180();
112
+}
113
+
114
+void loop(void) {
115
+  // picture loop
116
+  u8g.firstPage();  
117
+  do {
118
+    draw();
119
+  } while( u8g.nextPage() );
120
+  
121
+  // rebuild the picture after some delay
122
+  delay(500);
123
+}
124
+

+ 152
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/Rotation/Rotation.pde View File

@@ -0,0 +1,152 @@
1
+/*
2
+
3
+  HelloWorld.pde
4
+  
5
+  "Hello World!" example code.
6
+  
7
+  >>> Before compiling: Please remove comment from the constructor of the 
8
+  >>> connected graphics display (see below).
9
+  
10
+  Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
11
+  
12
+  Copyright (c) 2012, olikraus@gmail.com
13
+  All rights reserved.
14
+
15
+  Redistribution and use in source and binary forms, with or without modification, 
16
+  are permitted provided that the following conditions are met:
17
+
18
+  * Redistributions of source code must retain the above copyright notice, this list 
19
+    of conditions and the following disclaimer.
20
+    
21
+  * Redistributions in binary form must reproduce the above copyright notice, this 
22
+    list of conditions and the following disclaimer in the documentation and/or other 
23
+    materials provided with the distribution.
24
+
25
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
26
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
27
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
28
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
29
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
30
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
31
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
32
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
33
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
34
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
35
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
36
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
37
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
38
+  
39
+*/
40
+
41
+
42
+#include "U8glib.h"
43
+
44
+// setup u8g object, please remove comment from one of the following constructor calls
45
+// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
46
+
47
+//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
48
+//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
49
+//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
50
+//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
51
+//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
52
+//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
53
+//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
54
+//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
55
+//U8GLIB_DOGS102 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
56
+//U8GLIB_DOGM132 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
57
+//U8GLIB_DOGM128 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
58
+//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
59
+//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
60
+//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
61
+//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
62
+//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
63
+//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
64
+//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
65
+//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
66
+//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10);	// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
67
+//U8GLIB_ST7920_192X32_4X u8g(10);		// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
68
+//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
69
+//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
70
+//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
71
+//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
72
+//U8GLIB_LM6059 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
73
+//U8GLIB_LM6063 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
74
+//U8GLIB_DOGXL160_BW u8g(10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
75
+//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
76
+//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
77
+//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
78
+//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
79
+//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
80
+//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); 		// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
81
+//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
82
+//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
83
+//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
84
+//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 );  			// 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
85
+//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
86
+//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
87
+//U8GLIB_SSD1306_128X64 u8g(10, 9);		// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
88
+//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
89
+//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
90
+//U8GLIB_SSD1306_128X32 u8g(10, 9);             // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
91
+//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
92
+//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
93
+//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE);	// I2C
94
+//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE);	// I2C
95
+//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
96
+//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
97
+//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
98
+//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
99
+//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
100
+
101
+uint8_t offset = 0;
102
+
103
+void draw(void) {
104
+  // graphic commands to redraw the complete screen should be placed here  
105
+  u8g.setFont(u8g_font_unifont);
106
+  u8g.drawStr( 0+0, 20+0, "Hello!");
107
+  u8g.drawStr( 0+2, 20+16, "Hello!");
108
+  
109
+  u8g.drawBox(0, 0, 3, 3);
110
+  u8g.drawBox(u8g.getWidth()-6, 0, 6, 6);
111
+  u8g.drawBox(u8g.getWidth()-9, u8g.getHeight()-9, 9, 9);
112
+  u8g.drawBox(0, u8g.getHeight()-12, 12, 12);  
113
+}
114
+
115
+void setup(void) {
116
+}
117
+
118
+
119
+void rotate(void) {
120
+  static  uint8_t dir = 0;
121
+  static  unsigned long next_rotation = 0;
122
+  
123
+  if ( next_rotation < millis() )
124
+  {
125
+    switch(dir) {
126
+      case 0: u8g.undoRotation(); break;
127
+      case 1: u8g.setRot90(); break;
128
+      case 2: u8g.setRot180(); break;
129
+      case 3: u8g.setRot270(); offset = ( offset + 1 ) & 0x0f; break;
130
+    }
131
+    
132
+    dir++;
133
+    dir &= 3;
134
+    next_rotation = millis();
135
+    next_rotation += 1000;
136
+  }
137
+}
138
+
139
+void loop(void) {
140
+  // screen rotation 
141
+  rotate();
142
+  
143
+  // picture loop
144
+  u8g.firstPage();  
145
+  do {
146
+    draw();
147
+  } while( u8g.nextPage() );
148
+  
149
+  // rebuild the picture after some delay
150
+  delay(100);
151
+}
152
+

+ 141
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/Scale/Scale.pde View File

@@ -0,0 +1,141 @@
1
+/*
2
+
3
+  HelloWorld.pde
4
+  
5
+  "Hello World!" example code.
6
+  
7
+  >>> Before compiling: Please remove comment from the constructor of the 
8
+  >>> connected graphics display (see below).
9
+  
10
+  Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
11
+  
12
+  Copyright (c) 2012, olikraus@gmail.com
13
+  All rights reserved.
14
+
15
+  Redistribution and use in source and binary forms, with or without modification, 
16
+  are permitted provided that the following conditions are met:
17
+
18
+  * Redistributions of source code must retain the above copyright notice, this list 
19
+    of conditions and the following disclaimer.
20
+    
21
+  * Redistributions in binary form must reproduce the above copyright notice, this 
22
+    list of conditions and the following disclaimer in the documentation and/or other 
23
+    materials provided with the distribution.
24
+
25
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
26
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
27
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
28
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
29
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
30
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
31
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
32
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
33
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
34
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
35
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
36
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
37
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
38
+  
39
+*/
40
+
41
+
42
+#include "U8glib.h"
43
+
44
+// setup u8g object, please remove comment from one of the following constructor calls
45
+// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
46
+
47
+//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
48
+//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
49
+//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
50
+//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
51
+//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
52
+//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
53
+//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
54
+//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
55
+//U8GLIB_DOGS102 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
56
+//U8GLIB_DOGM132 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
57
+//U8GLIB_DOGM128 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
58
+//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
59
+//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
60
+//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
61
+//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
62
+//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
63
+//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
64
+//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
65
+//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
66
+//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10);	// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
67
+//U8GLIB_ST7920_192X32_4X u8g(10);		// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
68
+//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
69
+//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
70
+//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
71
+//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
72
+//U8GLIB_LM6059 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
73
+//U8GLIB_LM6063 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
74
+//U8GLIB_DOGXL160_BW u8g(10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
75
+//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
76
+//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
77
+//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
78
+//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
79
+//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
80
+//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); 		// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
81
+//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
82
+//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
83
+//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
84
+//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 );  			// 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
85
+//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
86
+//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
87
+//U8GLIB_SSD1306_128X64 u8g(10, 9);		// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
88
+//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
89
+//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
90
+//U8GLIB_SSD1306_128X32 u8g(10, 9);             // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
91
+//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
92
+//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
93
+//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE);	// I2C
94
+//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE);	// I2C
95
+//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
96
+//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
97
+//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
98
+//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
99
+//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
100
+
101
+
102
+void draw(void) {
103
+  // graphic commands to redraw the complete screen should be placed here  
104
+  u8g.setFont(u8g_font_unifont);
105
+  u8g.setFontPosTop();
106
+  u8g.drawStr(0, 1, "Hello");
107
+  u8g.drawHLine(0, 1+14, 40);
108
+  u8g.setScale2x2();					// Scale up all draw procedures
109
+  u8g.drawStr(0, 12, "Hello");			// actual display position is (0,24)
110
+  u8g.drawHLine(0, 12+14, 40);		// All other procedures are also affected
111
+  u8g.undoScale();					// IMPORTANT: Switch back to normal mode
112
+}
113
+
114
+void setup(void) {
115
+  
116
+  // flip screen, if required
117
+  u8g.setRot180();
118
+  
119
+  // set SPI backup if required
120
+  //u8g.setHardwareBackup(u8g_backup_avr_spi);
121
+
122
+  // assign default color value
123
+  if ( u8g.getMode() == U8G_MODE_R3G3B2 ) 
124
+    u8g.setColorIndex(255);     // white
125
+  else if ( u8g.getMode() == U8G_MODE_GRAY2BIT )
126
+    u8g.setColorIndex(3);         // max intensity
127
+  else if ( u8g.getMode() == U8G_MODE_BW )
128
+    u8g.setColorIndex(1);         // pixel on
129
+}
130
+
131
+void loop(void) {
132
+  // picture loop
133
+  u8g.firstPage();  
134
+  do {
135
+    draw();
136
+  } while( u8g.nextPage() );
137
+  
138
+  // rebuild the picture after some delay
139
+  delay(500);
140
+}
141
+

+ 154
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/TextRotX/TextRotX.pde View File

@@ -0,0 +1,154 @@
1
+/*
2
+
3
+  TextRotX.pde
4
+  
5
+  Text rotation example code.
6
+  
7
+  >>> Before compiling: Please remove comment from the constructor of the 
8
+  >>> connected graphics display (see below).
9
+  
10
+  Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
11
+  
12
+  Copyright (c) 2012, olikraus@gmail.com
13
+  All rights reserved.
14
+
15
+  Redistribution and use in source and binary forms, with or without modification, 
16
+  are permitted provided that the following conditions are met:
17
+
18
+  * Redistributions of source code must retain the above copyright notice, this list 
19
+    of conditions and the following disclaimer.
20
+    
21
+  * Redistributions in binary form must reproduce the above copyright notice, this 
22
+    list of conditions and the following disclaimer in the documentation and/or other 
23
+    materials provided with the distribution.
24
+
25
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
26
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
27
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
28
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
29
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
30
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
31
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
32
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
33
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
34
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
35
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
36
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
37
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
38
+  
39
+*/
40
+
41
+
42
+#include "U8glib.h"
43
+
44
+// setup u8g object, please remove comment from one of the following constructor calls
45
+// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
46
+
47
+//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
48
+//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
49
+//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
50
+//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
51
+//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
52
+//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
53
+//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
54
+//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
55
+//U8GLIB_DOGS102 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
56
+//U8GLIB_DOGM132 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
57
+//U8GLIB_DOGM128 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
58
+//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
59
+//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
60
+//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
61
+//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
62
+//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
63
+//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
64
+//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
65
+//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
66
+//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10);	// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
67
+//U8GLIB_ST7920_192X32_4X u8g(10);		// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
68
+//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
69
+//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
70
+//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
71
+//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
72
+//U8GLIB_LM6059 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
73
+//U8GLIB_LM6063 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
74
+//U8GLIB_DOGXL160_BW u8g(10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
75
+//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
76
+//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
77
+//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
78
+//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
79
+//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
80
+//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); 		// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
81
+//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
82
+//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
83
+//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
84
+//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 );  			// 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
85
+//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
86
+//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
87
+//U8GLIB_SSD1306_128X64 u8g(10, 9);		// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
88
+//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
89
+//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
90
+//U8GLIB_SSD1306_128X32 u8g(10, 9);             // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
91
+//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
92
+//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
93
+//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE);	// I2C
94
+//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE);	// I2C
95
+//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
96
+//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
97
+//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
98
+//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
99
+//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
100
+
101
+// graphic commands to redraw the complete screen should be placed here  
102
+void draw(void) {
103
+  u8g_uint_t mx, my;
104
+  
105
+  mx = u8g.getWidth();
106
+  mx >>= 1;
107
+  
108
+  my = u8g.getHeight();
109
+  my >>= 1;
110
+  
111
+  u8g.drawStr( mx, my, "Ag");
112
+  u8g.drawStr90( mx, my, "Ag");
113
+  u8g.drawStr180( mx, my, "Ag");
114
+  u8g.drawStr270( mx, my, "Ag");
115
+}
116
+
117
+void setup(void) {
118
+  u8g.setFont(u8g_font_9x18);
119
+}
120
+
121
+void change_font_pos(void) {
122
+  static  uint8_t dir = 0;
123
+  static  unsigned long next = 0;
124
+
125
+  if ( next < millis() )
126
+  {
127
+    switch(dir) {
128
+      case 0: u8g.setFontPosBottom(); break;
129
+      case 1: u8g.setFontPosBaseline(); break;
130
+      case 2: u8g.setFontPosCenter(); break;
131
+      case 3: u8g.setFontPosTop(); break;
132
+    }
133
+    
134
+    dir++;
135
+    dir &= 3;
136
+    next = millis();
137
+    next += 1000;
138
+  }
139
+}
140
+
141
+void loop(void) {
142
+  // change the font position  
143
+  change_font_pos();
144
+  
145
+  // picture loop
146
+  u8g.firstPage();  
147
+  do {
148
+    draw();
149
+  } while( u8g.nextPage() );
150
+  
151
+  // rebuild the picture after some delay
152
+  delay(100);
153
+}
154
+

+ 179
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/U8gLogo/U8gLogo.pde View File

@@ -0,0 +1,179 @@
1
+/*
2
+
3
+  U8gLogo.pde
4
+  
5
+  Put the U8GLIB logo on the display.
6
+  
7
+  >>> Before compiling: Please remove comment from the constructor of the 
8
+  >>> connected graphics display (see below).
9
+  
10
+  Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
11
+  
12
+  Copyright (c) 2012, olikraus@gmail.com
13
+  All rights reserved.
14
+
15
+  Redistribution and use in source and binary forms, with or without modification, 
16
+  are permitted provided that the following conditions are met:
17
+
18
+  * Redistributions of source code must retain the above copyright notice, this list 
19
+    of conditions and the following disclaimer.
20
+    
21
+  * Redistributions in binary form must reproduce the above copyright notice, this 
22
+    list of conditions and the following disclaimer in the documentation and/or other 
23
+    materials provided with the distribution.
24
+
25
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
26
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
27
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
28
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
29
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
30
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
31
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
32
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
33
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
34
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
35
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
36
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
37
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
38
+  
39
+*/
40
+
41
+
42
+#include "U8glib.h"
43
+
44
+// setup u8g object, please remove comment from one of the following constructor calls
45
+// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
46
+
47
+//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
48
+//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
49
+//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
50
+//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
51
+//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
52
+//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
53
+//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
54
+//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
55
+//U8GLIB_DOGS102 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
56
+//U8GLIB_DOGM132 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
57
+//U8GLIB_DOGM128 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
58
+//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
59
+//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
60
+//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
61
+//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
62
+//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
63
+//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
64
+//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
65
+//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
66
+//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10);	// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
67
+//U8GLIB_ST7920_192X32_4X u8g(10);		// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
68
+//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
69
+//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
70
+//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
71
+//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
72
+//U8GLIB_LM6059 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
73
+//U8GLIB_LM6063 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
74
+//U8GLIB_DOGXL160_BW u8g(10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
75
+//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
76
+//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
77
+//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
78
+//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
79
+//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
80
+//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); 		// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
81
+//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
82
+//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
83
+//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
84
+//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 );  			// 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
85
+//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
86
+//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
87
+//U8GLIB_SSD1306_128X64 u8g(10, 9);		// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
88
+//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
89
+//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
90
+//U8GLIB_SSD1306_128X32 u8g(10, 9);             // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
91
+//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
92
+//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
93
+//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE);	// I2C
94
+//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE);	// I2C
95
+//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
96
+//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
97
+//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
98
+//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
99
+//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
100
+
101
+
102
+void drawColorBox(void)
103
+{
104
+  u8g_uint_t w,h;
105
+  u8g_uint_t r, g, b;
106
+  
107
+  w = u8g.getWidth()/32;
108
+  h = u8g.getHeight()/8;
109
+  for( b = 0; b < 4; b++ )
110
+    for( g = 0; g < 8; g++ )
111
+      for( r = 0; r < 8; r++ )
112
+      {
113
+        u8g.setColorIndex((r<<5) |  (g<<2) | b );
114
+        u8g.drawBox(g*w + b*w*8, r*h, w, h);
115
+      }
116
+}
117
+
118
+void drawLogo(uint8_t d)
119
+{
120
+  u8g.setFont(u8g_font_gdr25r);
121
+  u8g.drawStr(0+d, 30+d, "U");
122
+  u8g.setFont(u8g_font_gdr30n);
123
+  u8g.drawStr90(23+d,10+d,"8");
124
+  u8g.setFont(u8g_font_gdr25r);
125
+  u8g.drawStr(53+d,30+d,"g");
126
+  
127
+  u8g.drawHLine(2+d, 35+d, 47);
128
+  u8g.drawVLine(45+d, 32+d, 12);
129
+}
130
+
131
+void drawURL(void)
132
+{
133
+  u8g.setFont(u8g_font_4x6);
134
+  if ( u8g.getHeight() < 59 )
135
+  {
136
+    u8g.drawStr(53,9,"code.google.com");
137
+    u8g.drawStr(77,18,"/p/u8glib");
138
+  }
139
+  else
140
+  {
141
+    u8g.drawStr(1,54,"code.google.com/p/u8glib");
142
+  }
143
+}
144
+
145
+
146
+void draw(void) {
147
+  if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
148
+    drawColorBox();
149
+  }
150
+  u8g.setColorIndex(1);
151
+  if ( U8G_MODE_GET_BITS_PER_PIXEL(u8g.getMode()) > 1 ) {
152
+    drawLogo(2);
153
+    u8g.setColorIndex(2);
154
+    drawLogo(1);
155
+    u8g.setColorIndex(3);
156
+  }
157
+  drawLogo(0);
158
+  drawURL();
159
+  
160
+}
161
+
162
+void setup(void) {
163
+  // flip screen, if required
164
+  //u8g.setRot180();
165
+}
166
+
167
+void loop(void) {
168
+  
169
+  // picture loop
170
+  u8g.firstPage();  
171
+  do {
172
+    draw();
173
+  u8g.setColorIndex(1);
174
+  } while( u8g.nextPage() );
175
+  
176
+  // rebuild the picture after some delay
177
+  delay(200);  
178
+}
179
+

+ 136
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/XBM/XBM.pde View File

@@ -0,0 +1,136 @@
1
+/*
2
+
3
+  XBM.pde
4
+  
5
+  drawXBM example code.
6
+  
7
+  >>> Before compiling: Please remove comment from the constructor of the 
8
+  >>> connected graphics display (see below).
9
+  
10
+  Universal 8bit Graphics Library, http://code.google.com/p/u8glib/
11
+  
12
+  Copyright (c) 2012, olikraus@gmail.com
13
+  All rights reserved.
14
+
15
+  Redistribution and use in source and binary forms, with or without modification, 
16
+  are permitted provided that the following conditions are met:
17
+
18
+  * Redistributions of source code must retain the above copyright notice, this list 
19
+    of conditions and the following disclaimer.
20
+    
21
+  * Redistributions in binary form must reproduce the above copyright notice, this 
22
+    list of conditions and the following disclaimer in the documentation and/or other 
23
+    materials provided with the distribution.
24
+
25
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
26
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
27
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
28
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
29
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
30
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
31
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
32
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
33
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
34
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
35
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
36
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
37
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
38
+  
39
+*/
40
+
41
+
42
+#include "U8glib.h"
43
+
44
+// setup u8g object, please remove comment from one of the following constructor calls
45
+// IMPORTANT NOTE: The complete list of supported devices is here: http://code.google.com/p/u8glib/wiki/device
46
+
47
+//U8GLIB_NHD27OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
48
+//U8GLIB_NHD27OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
49
+//U8GLIB_NHD27OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
50
+//U8GLIB_NHD27OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
51
+//U8GLIB_NHD31OLED_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
52
+//U8GLIB_NHD31OLED_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
53
+//U8GLIB_NHD31OLED_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
54
+//U8GLIB_NHD31OLED_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
55
+//U8GLIB_DOGS102 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
56
+//U8GLIB_DOGM132 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
57
+//U8GLIB_DOGM128 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
58
+//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
59
+//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
60
+//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
61
+//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
62
+//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
63
+//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
64
+//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
65
+//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
66
+//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10);	// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
67
+//U8GLIB_ST7920_192X32_4X u8g(10);		// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
68
+//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
69
+//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
70
+//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
71
+//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
72
+//U8GLIB_LM6059 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
73
+//U8GLIB_LM6063 u8g(13, 11, 10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
74
+//U8GLIB_DOGXL160_BW u8g(10, 9);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
75
+//U8GLIB_DOGXL160_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
76
+//U8GLIB_DOGXL160_2X_BW u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
77
+//U8GLIB_DOGXL160_2X_GR u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
78
+//U8GLIB_PCD8544 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
79
+//U8GLIB_PCF8812 u8g(13, 11, 10, 9, 8);		// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, Reset = 8
80
+//U8GLIB_KS0108_128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 14, 15, 17, 16); 		// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs1=14, cs2=15,di=17,rw=16
81
+//U8GLIB_LC7981_160X80 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
82
+//U8GLIB_LC7981_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
83
+//U8GLIB_LC7981_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7,  18, 14, 15, 17, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, cs=14 ,di=15,rw=17, reset = 16
84
+//U8GLIB_ILI9325D_320x240 u8g(18,17,19,U8G_PIN_NONE,16 );  			// 8Bit Com: D0..D7: 0,1,2,3,4,5,6,7 en=wr=18, cs=17, rs=19, rd=U8G_PIN_NONE, reset = 16
85
+//U8GLIB_SBN1661_122X32 u8g(8,9,10,11,4,5,6,7,14,15, 17, U8G_PIN_NONE, 16); 	// 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 cs1=14, cs2=15,di=17,rw=16,reset = 16
86
+//U8GLIB_SSD1306_128X64 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
87
+//U8GLIB_SSD1306_128X64 u8g(10, 9);		// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
88
+//U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
89
+//U8GLIB_SSD1306_128X32 u8g(13, 11, 10, 9);	// SW SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
90
+//U8GLIB_SSD1306_128X32 u8g(10, 9);             // HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
91
+//U8GLIB_SSD1306_128X32 u8g(U8G_I2C_OPT_NONE);	// HW SPI Com: CS = 10, A0 = 9 (Hardware Pins are  SCK = 13 and MOSI = 11)
92
+//U8GLIB_SSD1309_128X64 u8g(13, 11, 10, 9);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9
93
+//U8GLIB_SSD1327_96X96_GR u8g(U8G_I2C_OPT_NONE);	// I2C
94
+//U8GLIB_SSD1327_96X96_2X_GR u8g(U8G_I2C_OPT_NONE);	// I2C
95
+//U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
96
+//U8GLIB_NHD_C12832 u8g(13, 11, 10, 9, 8);	// SPI Com: SCK = 13, MOSI = 11, CS = 10, A0 = 9, RST = 8
97
+//U8GLIB_T6963_240X128 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
98
+//U8GLIB_T6963_240X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
99
+//U8GLIB_T6963_128X64 u8g(8, 9, 10, 11, 4, 5, 6, 7, 14, 15, 17, 18, 16); // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7, cs=14, a0=15, wr=17, rd=18, reset=16
100
+
101
+#define u8g_logo_width 38
102
+#define u8g_logo_height 24
103
+//static unsigned char u8g_logo_bits[] = {
104
+static unsigned char u8g_logo_bits[] U8G_PROGMEM = {
105
+   0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xe0, 0xe0,
106
+   0xff, 0xff, 0x3f, 0xe3, 0xe1, 0xff, 0xff, 0x3f, 0xf3, 0xf1, 0xff, 0xff,
107
+   0x3f, 0xf3, 0xf1, 0xfe, 0xbf, 0x37, 0xf3, 0x11, 0x1c, 0x1f, 0x30, 0xf3,
108
+   0x01, 0x08, 0x8c, 0x20, 0xf3, 0x01, 0x00, 0xc0, 0x39, 0xf3, 0x81, 0xc7,
109
+   0xc1, 0x39, 0xf3, 0xc1, 0xc7, 0xc9, 0x38, 0xf3, 0xc1, 0xc3, 0x19, 0x3c,
110
+   0xe3, 0x89, 0x01, 0x98, 0x3f, 0xc7, 0x18, 0x00, 0x08, 0x3e, 0x0f, 0x3c,
111
+   0x70, 0x1c, 0x30, 0x3f, 0xff, 0xfc, 0x87, 0x31, 0xff, 0xff, 0xbf, 0xc7,
112
+   0x23, 0x01, 0x00, 0x00, 0xc6, 0x23, 0x03, 0x00, 0x00, 0x0e, 0x30, 0xff,
113
+   0xff, 0x3f, 0x1f, 0x3c, 0xff, 0xff, 0x3f, 0xff, 0x3f, 0xff, 0xff, 0x3f,
114
+   0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0x3f };
115
+
116
+void draw(void) {
117
+  // graphic commands to redraw the complete screen should be placed here  
118
+  u8g.drawXBMP( 0, 0, u8g_logo_width, u8g_logo_height, u8g_logo_bits);
119
+}
120
+
121
+void setup(void) {
122
+  // flip screen, if required
123
+  // u8g.setRot180();
124
+}
125
+
126
+void loop(void) {
127
+  // picture loop
128
+  u8g.firstPage();  
129
+  do {
130
+    draw();
131
+  } while( u8g.nextPage() );
132
+  
133
+  // rebuild the picture after some delay
134
+  delay(500);
135
+}
136
+

+ 80
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/license.txt View File

@@ -0,0 +1,80 @@
1
+
2
+The U8glib code (http://code.google.com/p/u8glib/) is licensed under the terms of 
3
+the new-bsd license (two-clause bsd license).
4
+See also: http://www.opensource.org/licenses/bsd-license.php
5
+
6
+The repository and optionally the releases contain icons, which are
7
+derived from the WPZOOM Developer Icon Set:
8
+http://www.wpzoom.com/wpzoom/new-freebie-wpzoom-developer-icon-set-154-free-icons/
9
+WPZOOM Developer Icon Set by WPZOOM is licensed under a Creative Commons 
10
+Attribution-ShareAlike 3.0 Unported License.
11
+
12
+Fonts are licensed under different conditions.
13
+See http://code.google.com/p/u8glib/wiki/fontgroup for
14
+detailed information on the licensing conditions for each font.
15
+
16
+============ X11 Fonts COUR, HELV, NCEN, TIM, SYMB ============
17
+
18
+For fonts derived from the following files, the license below applies.
19
+COURB08.BDF COURB10.BDF COURB12.BDF COURB14.BDF COURB18.BDF 
20
+COURB24.BDF COURR08.BDF COURR10.BDF COURR12.BDF COURR14.BDF 
21
+COURR18.BDF COURR24.BDF HELVB08.BDF HELVB10.BDF HELVB12.BDF HELVB14.BDF 
22
+HELVB18.BDF HELVB24.BDF HELVR08.BDF HELVR10.BDF HELVR12.BDF HELVR14.BDF 
23
+HELVR18.BDF HELVR24.BDF NCENB08.BDF NCENB10.BDF NCENB12.BDF 
24
+NCENB14.BDF NCENB18.BDF NCENB24.BDF NCENR08.BDF NCENR10.BDF 
25
+NCENR12.BDF NCENR14.BDF NCENR18.BDF NCENR24.BDF SYMB08.BDF SYMB10.BDF 
26
+SYMB12.BDF SYMB14.BDF SYMB18.BDF SYMB24.BDF TIMB08.BDF TIMB10.BDF 
27
+TIMB12.BDF TIMB14.BDF TIMB18.BDF TIMB24.BDF TIMR08.BDF TIMR10.BDF 
28
+TIMR12.BDF TIMR14.BDF TIMR18.BDF TIMR24.BDF 
29
+
30
+Copyright 1984-1989, 1994 Adobe Systems Incorporated.
31
+Copyright 1988, 1994 Digital Equipment Corporation.
32
+
33
+Adobe is a trademark of Adobe Systems Incorporated which may be
34
+registered in certain jurisdictions.
35
+Permission to use these trademarks is hereby granted only in
36
+association with the images described in this file.
37
+
38
+Permission to use, copy, modify, distribute and sell this software
39
+and its documentation for any purpose and without fee is hereby
40
+granted, provided that the above copyright notices appear in all
41
+copies and that both those copyright notices and this permission
42
+notice appear in supporting documentation, and that the names of
43
+Adobe Systems and Digital Equipment Corporation not be used in
44
+advertising or publicity pertaining to distribution of the software
45
+without specific, written prior permission.  Adobe Systems and
46
+Digital Equipment Corporation make no representations about the
47
+suitability of this software for any purpose.  It is provided "as
48
+is" without express or implied warranty.
49
+
50
+
51
+============ BSD License for U8glib Code ============
52
+
53
+Universal 8bit Graphics Library (http://code.google.com/p/u8glib/)
54
+
55
+Copyright (c) 2011, olikraus@gmail.com
56
+All rights reserved.
57
+
58
+Redistribution and use in source and binary forms, with or without modification, 
59
+are permitted provided that the following conditions are met:
60
+
61
+* Redistributions of source code must retain the above copyright notice, this list 
62
+  of conditions and the following disclaimer.
63
+  
64
+* Redistributions in binary form must reproduce the above copyright notice, this 
65
+  list of conditions and the following disclaimer in the documentation and/or other 
66
+  materials provided with the distribution.
67
+
68
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
69
+CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
70
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
71
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
72
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
73
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
74
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
75
+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
76
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
77
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
78
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
79
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
80
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  

+ 2392
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/chessengine.c
File diff suppressed because it is too large
View File


+ 1606
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g.h
File diff suppressed because it is too large
View File


+ 177
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_bitmap.c View File

@@ -0,0 +1,177 @@
1
+/*
2
+
3
+  u8g_bitmap.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+
35
+*/
36
+
37
+#include "u8g.h"
38
+
39
+void u8g_DrawHBitmap(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, const uint8_t *bitmap)
40
+{
41
+  while( cnt > 0 )
42
+  {
43
+    u8g_Draw8Pixel(u8g, x, y, 0, *bitmap);
44
+    bitmap++;
45
+    cnt--;
46
+    x+=8;
47
+  }
48
+}
49
+
50
+void u8g_DrawBitmap(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, u8g_uint_t h, const uint8_t *bitmap)
51
+{
52
+  if ( u8g_IsBBXIntersection(u8g, x, y, cnt*8, h) == 0 )
53
+    return;
54
+  while( h > 0 )
55
+  {
56
+    u8g_DrawHBitmap(u8g, x, y, cnt, bitmap);
57
+    bitmap += cnt;
58
+    y++;
59
+    h--;
60
+  }
61
+}
62
+
63
+
64
+void u8g_DrawHBitmapP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, const u8g_pgm_uint8_t *bitmap)
65
+{
66
+  while( cnt > 0 )
67
+  {
68
+    u8g_Draw8Pixel(u8g, x, y, 0, u8g_pgm_read(bitmap));
69
+    bitmap++;
70
+    cnt--;
71
+    x+=8;
72
+  }
73
+}
74
+
75
+void u8g_DrawBitmapP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t cnt, u8g_uint_t h, const u8g_pgm_uint8_t *bitmap)
76
+{
77
+  if ( u8g_IsBBXIntersection(u8g, x, y, cnt*8, h) == 0 )
78
+    return;
79
+  while( h > 0 )
80
+  {
81
+    u8g_DrawHBitmapP(u8g, x, y, cnt, bitmap);
82
+    bitmap += cnt;
83
+    y++;
84
+    h--;
85
+  }
86
+}
87
+
88
+/*=========================================================================*/
89
+
90
+static void u8g_DrawHXBM(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, const uint8_t *bitmap)
91
+{
92
+  uint8_t d;
93
+  x+=7;
94
+  while( w >= 8 )
95
+  {
96
+    u8g_Draw8Pixel(u8g, x, y, 2, *bitmap);
97
+    bitmap++;
98
+    w-= 8;
99
+    x+=8;
100
+  }
101
+  if ( w > 0 )
102
+  {
103
+    d = *bitmap;
104
+    x -= 7;
105
+    do
106
+    {
107
+      if ( d & 1 )
108
+        u8g_DrawPixel(u8g, x, y);
109
+      x++;
110
+      w--;
111
+      d >>= 1;      
112
+    } while ( w > 0 );
113
+  }
114
+}
115
+
116
+void u8g_DrawXBM(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, const uint8_t *bitmap)
117
+{
118
+  u8g_uint_t b;
119
+  b = w;
120
+  b += 7;
121
+  b >>= 3;
122
+  
123
+  if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
124
+    return;
125
+  
126
+  while( h > 0 )
127
+  {
128
+    u8g_DrawHXBM(u8g, x, y, w, bitmap);
129
+    bitmap += b;
130
+    y++;
131
+    h--;
132
+  }
133
+}
134
+
135
+static void u8g_DrawHXBMP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, const u8g_pgm_uint8_t *bitmap)
136
+{
137
+  uint8_t d;
138
+  x+=7;
139
+  while( w >= 8 )
140
+  {
141
+    u8g_Draw8Pixel(u8g, x, y, 2, u8g_pgm_read(bitmap));
142
+    bitmap++;
143
+    w-= 8;
144
+    x+=8;
145
+  }
146
+  if ( w > 0 )
147
+  {
148
+    d = u8g_pgm_read(bitmap);
149
+    x -= 7;
150
+    do
151
+    {
152
+      if ( d & 1 )
153
+        u8g_DrawPixel(u8g, x, y);
154
+      x++;
155
+      w--;
156
+      d >>= 1;      
157
+    } while ( w > 0 );
158
+  }
159
+}
160
+
161
+void u8g_DrawXBMP(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h, const u8g_pgm_uint8_t *bitmap)
162
+{
163
+  u8g_uint_t b;
164
+  b = w;
165
+  b += 7;
166
+  b >>= 3;
167
+  
168
+  if ( u8g_IsBBXIntersection(u8g, x, y, w, h) == 0 )
169
+    return;
170
+  while( h > 0 )
171
+  {
172
+    u8g_DrawHXBMP(u8g, x, y, w, bitmap);
173
+    bitmap += b;
174
+    y++;
175
+    h--;
176
+  }
177
+}

+ 382
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_circle.c View File

@@ -0,0 +1,382 @@
1
+/*
2
+
3
+  u8g_circle.c
4
+
5
+  Utility to draw empty and filled circles.
6
+  
7
+  Universal 8bit Graphics Library
8
+  
9
+  Copyright (c) 2011, bjthom@gmail.com
10
+  u8g_DrawCircle & u8g_DrawDisc by olikraus@gmail.com
11
+  
12
+  All rights reserved.
13
+
14
+  Redistribution and use in source and binary forms, with or without modification, 
15
+  are permitted provided that the following conditions are met:
16
+
17
+  * Redistributions of source code must retain the above copyright notice, this list 
18
+    of conditions and the following disclaimer.
19
+    
20
+  * Redistributions in binary form must reproduce the above copyright notice, this 
21
+    list of conditions and the following disclaimer in the documentation and/or other 
22
+    materials provided with the distribution.
23
+
24
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
25
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
26
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
27
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
28
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
29
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
30
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
31
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
32
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
33
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
34
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
35
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
36
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
37
+  
38
+  Addition to the U8G Library 02/25/12
39
+  
40
+  
41
+*/
42
+
43
+#include "u8g.h"
44
+
45
+#ifdef OLD_CODE
46
+
47
+void circ_upperRight(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0) {
48
+  u8g_DrawPixel(u8g, x0 + x, y0 - y);
49
+  u8g_DrawPixel(u8g, x0 + y, y0 - x);
50
+}
51
+		
52
+void circ_upperLeft(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0) {
53
+  u8g_DrawPixel(u8g, x0 - x, y0 - y);
54
+  u8g_DrawPixel(u8g, x0 - y, y0 - x);
55
+}
56
+		
57
+void circ_lowerRight(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0) {
58
+  u8g_DrawPixel(u8g, x0 + x, y0 + y);
59
+  u8g_DrawPixel(u8g, x0 + y, y0 + x);
60
+}
61
+		
62
+void circ_lowerLeft(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0) {
63
+  u8g_DrawPixel(u8g, x0 - x, y0 + y);
64
+  u8g_DrawPixel(u8g, x0 - y, y0 + x);
65
+}
66
+			
67
+void circ_all(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0) {
68
+  circ_upperRight(u8g, x, y, x0, y0);
69
+  circ_upperLeft(u8g, x, y, x0, y0);
70
+  circ_lowerRight(u8g, x, y, x0, y0);
71
+  circ_lowerLeft(u8g, x, y, x0, y0);
72
+}
73
+
74
+void u8g_DrawEmpCirc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option)
75
+{
76
+  if ( u8g_IsBBXIntersection(u8g, x0-rad-1, y0-rad-1, 2*rad+1, 2*rad+1) == 0)
77
+    return;
78
+
79
+  int f = 1 - rad;
80
+  int ddF_x = 1;
81
+  int ddF_y = -2*rad;
82
+  uint8_t x = 0;
83
+  uint8_t y = rad;
84
+
85
+  void ( *circ_util )(u8g_t *, u8g_uint_t, u8g_uint_t, u8g_uint_t, u8g_uint_t);
86
+  
87
+  switch (option)
88
+  {
89
+	case U8G_CIRC_UPPER_RIGHT:
90
+		u8g_DrawPixel(u8g, x0, y0 - rad);
91
+		u8g_DrawPixel(u8g, x0 + rad, y0);
92
+		circ_util = circ_upperRight;
93
+		break;
94
+	case U8G_CIRC_UPPER_LEFT:
95
+		u8g_DrawPixel(u8g, x0, y0 - rad);
96
+		u8g_DrawPixel(u8g, x0 - rad, y0);
97
+		circ_util = circ_upperLeft;
98
+		break;
99
+	case U8G_CIRC_LOWER_RIGHT:
100
+		u8g_DrawPixel(u8g, x0, y0 + rad);
101
+		u8g_DrawPixel(u8g, x0 + rad, y0);
102
+		circ_util = circ_lowerRight;
103
+		break;
104
+	case U8G_CIRC_LOWER_LEFT:
105
+		u8g_DrawPixel(u8g, x0, y0 + rad);
106
+		u8g_DrawPixel(u8g, x0 - rad, y0);
107
+		circ_util = circ_lowerLeft;
108
+		break;
109
+        default:
110
+	case U8G_CIRC_ALL:
111
+		u8g_DrawPixel(u8g, x0, y0 + rad);
112
+		u8g_DrawPixel(u8g, x0, y0 - rad);
113
+		u8g_DrawPixel(u8g, x0 + rad, y0);
114
+		u8g_DrawPixel(u8g, x0 - rad, y0);
115
+		circ_util = circ_all;
116
+		break;
117
+  }
118
+  
119
+  while( x < y )
120
+  {
121
+    if(f >= 0) 
122
+    {
123
+      y--;
124
+      ddF_y += 2;
125
+      f += ddF_y;
126
+    }
127
+    x++;
128
+    ddF_x += 2;
129
+    f += ddF_x;
130
+    
131
+    circ_util(u8g, x, y, x0, y0);
132
+  }
133
+}
134
+
135
+
136
+void u8g_DrawFillCirc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option)
137
+{
138
+  if ( u8g_IsBBXIntersection(u8g, x0-rad-1, y0-rad-1, 2*rad+1, 2*rad+1) == 0)
139
+    return;
140
+
141
+  int f = 1 - rad;
142
+  int ddF_x = 1;
143
+  int ddF_y = -2*rad;
144
+  uint8_t x = 0;
145
+  uint8_t y = rad;
146
+  
147
+  // Draw vertical diameter at the horiz. center
148
+  // u8g_DrawVLine(u8g, x0, y0 - rad, 2*rad+1);
149
+
150
+  if (option == U8G_CIRC_UPPER_LEFT || option == U8G_CIRC_UPPER_RIGHT) {
151
+	u8g_DrawVLine(u8g, x0, y0 - rad, rad+1);
152
+  }
153
+  else if (option == U8G_CIRC_LOWER_LEFT || option == U8G_CIRC_LOWER_RIGHT) {
154
+	u8g_DrawVLine(u8g, x0, y0, rad+1);
155
+  }
156
+  else {
157
+	u8g_DrawVLine(u8g, x0, y0 - rad, 2*rad+1);
158
+  }
159
+  
160
+  while( x < y )
161
+  {
162
+    if(f >= 0) 
163
+    {
164
+      y--;
165
+      ddF_y += 2;
166
+      f += ddF_y;
167
+    }
168
+    x++;
169
+    ddF_x += 2;
170
+    f += ddF_x;
171
+    
172
+	//Draw vertical lines from one point to another
173
+	
174
+	switch (option)
175
+	{
176
+		case U8G_CIRC_UPPER_RIGHT:
177
+			u8g_DrawVLine(u8g, x0+x, y0-y, y+1);
178
+			u8g_DrawVLine(u8g, x0+y, y0-x, x+1);
179
+			break;
180
+		case U8G_CIRC_UPPER_LEFT:
181
+			u8g_DrawVLine(u8g, x0-x, y0-y, y+1);
182
+			u8g_DrawVLine(u8g, x0-y, y0-x, x+1);
183
+			break;
184
+		case U8G_CIRC_LOWER_RIGHT:
185
+			u8g_DrawVLine(u8g, x0+x, y0, y+1);
186
+			u8g_DrawVLine(u8g, x0+y, y0, x+1);
187
+			break;
188
+		case U8G_CIRC_LOWER_LEFT:
189
+			u8g_DrawVLine(u8g, x0-x, y0, y+1);
190
+			u8g_DrawVLine(u8g, x0-y, y0, x+1);
191
+			break;
192
+		case U8G_CIRC_ALL:
193
+			u8g_DrawVLine(u8g, x0+x, y0-y, 2*y+1);
194
+			u8g_DrawVLine(u8g, x0-x, y0-y, 2*y+1);
195
+			u8g_DrawVLine(u8g, x0+y, y0-x, 2*x+1);
196
+			u8g_DrawVLine(u8g, x0-y, y0-x, 2*x+1);
197
+			break;
198
+	}
199
+  }
200
+}
201
+
202
+#endif 
203
+
204
+/*=========================================================================*/
205
+
206
+static void u8g_draw_circle_section(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0, uint8_t option) U8G_NOINLINE;
207
+
208
+static void u8g_draw_circle_section(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0, uint8_t option)
209
+{
210
+    /* upper right */
211
+    if ( option & U8G_DRAW_UPPER_RIGHT )
212
+    {
213
+      u8g_DrawPixel(u8g, x0 + x, y0 - y);
214
+      u8g_DrawPixel(u8g, x0 + y, y0 - x);
215
+    }
216
+    
217
+    /* upper left */
218
+    if ( option & U8G_DRAW_UPPER_LEFT )
219
+    {
220
+      u8g_DrawPixel(u8g, x0 - x, y0 - y);
221
+      u8g_DrawPixel(u8g, x0 - y, y0 - x);
222
+    }
223
+    
224
+    /* lower right */
225
+    if ( option & U8G_DRAW_LOWER_RIGHT )
226
+    {
227
+      u8g_DrawPixel(u8g, x0 + x, y0 + y);
228
+      u8g_DrawPixel(u8g, x0 + y, y0 + x);
229
+    }
230
+    
231
+    /* lower left */
232
+    if ( option & U8G_DRAW_LOWER_LEFT )
233
+    {
234
+      u8g_DrawPixel(u8g, x0 - x, y0 + y);
235
+      u8g_DrawPixel(u8g, x0 - y, y0 + x);
236
+    }
237
+}
238
+
239
+void u8g_draw_circle(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option)
240
+{
241
+    u8g_int_t f;
242
+    u8g_int_t ddF_x;
243
+    u8g_int_t ddF_y;
244
+    u8g_uint_t x;
245
+    u8g_uint_t y;
246
+
247
+    f = 1;
248
+    f -= rad;
249
+    ddF_x = 1;
250
+    ddF_y = 0;
251
+    ddF_y -= rad;
252
+    ddF_y *= 2;
253
+    x = 0;
254
+    y = rad;
255
+
256
+    u8g_draw_circle_section(u8g, x, y, x0, y0, option);
257
+    
258
+    while ( x < y )
259
+    {
260
+      if (f >= 0) 
261
+      {
262
+        y--;
263
+        ddF_y += 2;
264
+        f += ddF_y;
265
+      }
266
+      x++;
267
+      ddF_x += 2;
268
+      f += ddF_x;
269
+
270
+      u8g_draw_circle_section(u8g, x, y, x0, y0, option);    
271
+    }
272
+}
273
+
274
+void u8g_DrawCircle(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option)
275
+{
276
+  /* check for bounding box */
277
+  {
278
+    u8g_uint_t radp, radp2;
279
+    
280
+    radp = rad;
281
+    radp++;
282
+    radp2 = radp;
283
+    radp2 *= 2;
284
+    
285
+    if ( u8g_IsBBXIntersection(u8g, x0-radp, y0-radp, radp2, radp2) == 0)
286
+      return;    
287
+  }
288
+  
289
+  /* draw circle */
290
+  u8g_draw_circle(u8g, x0, y0, rad, option);
291
+}
292
+
293
+static void u8g_draw_disc_section(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0, uint8_t option) U8G_NOINLINE;
294
+
295
+static void u8g_draw_disc_section(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t x0, u8g_uint_t y0, uint8_t option)
296
+{
297
+    /* upper right */
298
+    if ( option & U8G_DRAW_UPPER_RIGHT )
299
+    {
300
+      u8g_DrawVLine(u8g, x0+x, y0-y, y+1);
301
+      u8g_DrawVLine(u8g, x0+y, y0-x, x+1);
302
+    }
303
+    
304
+    /* upper left */
305
+    if ( option & U8G_DRAW_UPPER_LEFT )
306
+    {
307
+      u8g_DrawVLine(u8g, x0-x, y0-y, y+1);
308
+      u8g_DrawVLine(u8g, x0-y, y0-x, x+1);
309
+    }
310
+    
311
+    /* lower right */
312
+    if ( option & U8G_DRAW_LOWER_RIGHT )
313
+    {
314
+      u8g_DrawVLine(u8g, x0+x, y0, y+1);
315
+      u8g_DrawVLine(u8g, x0+y, y0, x+1);
316
+    }
317
+    
318
+    /* lower left */
319
+    if ( option & U8G_DRAW_LOWER_LEFT )
320
+    {
321
+      u8g_DrawVLine(u8g, x0-x, y0, y+1);
322
+      u8g_DrawVLine(u8g, x0-y, y0, x+1);
323
+    }
324
+}
325
+
326
+void u8g_draw_disc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option)
327
+{
328
+  u8g_int_t f;
329
+  u8g_int_t ddF_x;
330
+  u8g_int_t ddF_y;
331
+  u8g_uint_t x;
332
+  u8g_uint_t y;
333
+
334
+  f = 1;
335
+  f -= rad;
336
+  ddF_x = 1;
337
+  ddF_y = 0;
338
+  ddF_y -= rad;
339
+  ddF_y *= 2;
340
+  x = 0;
341
+  y = rad;
342
+
343
+  u8g_draw_disc_section(u8g, x, y, x0, y0, option);
344
+  
345
+  while ( x < y )
346
+  {
347
+    if (f >= 0) 
348
+    {
349
+      y--;
350
+      ddF_y += 2;
351
+      f += ddF_y;
352
+    }
353
+    x++;
354
+    ddF_x += 2;
355
+    f += ddF_x;
356
+
357
+    u8g_draw_disc_section(u8g, x, y, x0, y0, option);    
358
+  }
359
+}
360
+
361
+void u8g_DrawDisc(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t rad, uint8_t option)
362
+{
363
+  /* check for bounding box */
364
+  {
365
+    u8g_uint_t radp, radp2;
366
+    
367
+    radp = rad;
368
+    radp++;
369
+    radp2 = radp;
370
+    radp2 *= 2;
371
+    
372
+    if ( u8g_IsBBXIntersection(u8g, x0-radp, y0-radp, radp2, radp2) == 0)
373
+      return;    
374
+  }
375
+  
376
+  /* draw disc */
377
+  u8g_draw_disc(u8g, x0, y0, rad, option);
378
+}
379
+
380
+
381
+
382
+

+ 156
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_clip.c View File

@@ -0,0 +1,156 @@
1
+/*
2
+
3
+  u8g_clip.c
4
+  
5
+  procedures for clipping
6
+  taken over from procs in u8g_pb.c
7
+
8
+  Universal 8bit Graphics Library
9
+  
10
+  Copyright (c) 2012, olikraus@gmail.com
11
+  All rights reserved.
12
+
13
+  Redistribution and use in source and binary forms, with or without modification, 
14
+  are permitted provided that the following conditions are met:
15
+
16
+  * Redistributions of source code must retain the above copyright notice, this list 
17
+    of conditions and the following disclaimer.
18
+    
19
+  * Redistributions in binary form must reproduce the above copyright notice, this 
20
+    list of conditions and the following disclaimer in the documentation and/or other 
21
+    materials provided with the distribution.
22
+
23
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
24
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
25
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
26
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
27
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
28
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
29
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
30
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
31
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
32
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
33
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
34
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
35
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
36
+  
37
+  Notes
38
+  
39
+  This is one of the most critical parts of u8glib. It must be fast, but still reliable.
40
+  Based on the intersection program (see tools folder), there is minimized version of
41
+  the condition for the intersaction test:
42
+    minimized version
43
+    ---1----0 1             b1 <= a2 && b1 > b2
44
+    -----1--0 1             b2 >= a1 && b1 > b2
45
+    ---1-1--- 1             b1 <= a2 && b2 >= a1
46
+  It includes the assumption, that a1 <= a2 is always true (correct, because
47
+  a1, a2 are the page dimensions.
48
+
49
+  The direct implementation of the above result is done in:
50
+  uint8_t u8g_is_intersection_boolean(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1)
51
+  However, this is slower than a decision tree version:  
52
+  static uint8_t u8g_is_intersection_decision_tree(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1) 
53
+  Also suprising is, that he the macro implementation is slower than the inlined version.
54
+  
55
+  The decision tree is based on the expansion of the truth table.
56
+  
57
+*/
58
+
59
+#include "u8g.h"
60
+
61
+#ifdef __GNUC__
62
+#define U8G_ALWAYS_INLINE __attribute__((always_inline))
63
+#else
64
+#define U8G_ALWAYS_INLINE
65
+ #endif 
66
+
67
+/*
68
+  intersection assumptions:
69
+    a1 <= a2 is always true    
70
+    
71
+    minimized version
72
+    ---1----0 1             b1 <= a2 && b1 > b2
73
+    -----1--0 1             b2 >= a1 && b1 > b2
74
+    ---1-1--- 1             b1 <= a2 && b2 >= a1
75
+  */
76
+
77
+#ifdef OLD_CODE_WHICH_IS_TOO_SLOW
78
+static uint8_t u8g_is_intersection_boolean(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1)
79
+{
80
+  uint8_t c1, c2, c3, tmp;
81
+  c1 = v0 <= a1;
82
+  c2 = v1 >= a0;
83
+  c3 = v0 > v1;
84
+  
85
+  tmp = c1;
86
+  c1 &= c2;
87
+  c2 &= c3;
88
+  c3 &= tmp;
89
+  c1 |= c2;
90
+  c1 |= c3;
91
+  return c1 & 1;
92
+}
93
+#endif
94
+
95
+#define U8G_IS_INTERSECTION_MACRO(a0,a1,v0,v1) ((uint8_t)( (v0) <= (a1) ) ? ( ( (v1) >= (a0) ) ? ( 1 ) : ( (v0) > (v1) ) ) : ( ( (v1) >= (a0) ) ? ( (v0) > (v1) ) : ( 0 ) ))
96
+
97
+static uint8_t u8g_is_intersection_decision_tree(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1)  U8G_ALWAYS_INLINE;
98
+static uint8_t u8g_is_intersection_decision_tree(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1) 
99
+{
100
+  /* surprisingly the macro leads to larger code */
101
+  /* return U8G_IS_INTERSECTION_MACRO(a0,a1,v0,v1); */
102
+  if ( v0 <= a1 )
103
+  {
104
+    if ( v1 >= a0 )
105
+    {
106
+      return 1;
107
+    }
108
+    else
109
+    {
110
+      if ( v0 > v1 )
111
+      {
112
+	return 1;
113
+      }
114
+      else
115
+      {
116
+	return 0;
117
+      }
118
+    }
119
+  }
120
+  else
121
+  {
122
+    if ( v1 >= a0 )
123
+    {
124
+      if ( v0 > v1 )
125
+      {
126
+	return 1;
127
+      }
128
+      else
129
+      {
130
+	return 0;
131
+      }
132
+    }
133
+    else
134
+    {
135
+      return 0;
136
+    }
137
+  }
138
+}
139
+
140
+
141
+uint8_t u8g_IsBBXIntersection(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
142
+{
143
+  register u8g_uint_t tmp;
144
+  tmp = y;
145
+  tmp += h;
146
+  tmp--;
147
+  if ( u8g_is_intersection_decision_tree(u8g->current_page.y0, u8g->current_page.y1, y, tmp) == 0 )
148
+    return 0; 
149
+  
150
+  tmp = x;
151
+  tmp += w;
152
+  tmp--;
153
+  return u8g_is_intersection_decision_tree(u8g->current_page.x0, u8g->current_page.x1, x, tmp);
154
+}
155
+
156
+

+ 173
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_api.c View File

@@ -0,0 +1,173 @@
1
+/*
2
+
3
+  u8g_com_api.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+  
35
+*/
36
+
37
+#include "u8g.h"
38
+
39
+uint8_t u8g_InitCom(u8g_t *u8g, u8g_dev_t *dev)
40
+{
41
+  return dev->com_fn(u8g, U8G_COM_MSG_INIT, 0, NULL);
42
+}
43
+
44
+void u8g_StopCom(u8g_t *u8g, u8g_dev_t *dev)
45
+{
46
+  dev->com_fn(u8g, U8G_COM_MSG_STOP, 0, NULL);
47
+}
48
+
49
+/* cs contains the chip number, which should be enabled */
50
+void u8g_SetChipSelect(u8g_t *u8g, u8g_dev_t *dev, uint8_t cs)
51
+{
52
+  dev->com_fn(u8g, U8G_COM_MSG_CHIP_SELECT, cs, NULL);
53
+}
54
+
55
+void u8g_SetResetLow(u8g_t *u8g, u8g_dev_t *dev)
56
+{
57
+  dev->com_fn(u8g, U8G_COM_MSG_RESET, 0, NULL);
58
+}
59
+
60
+void u8g_SetResetHigh(u8g_t *u8g, u8g_dev_t *dev)
61
+{
62
+  dev->com_fn(u8g, U8G_COM_MSG_RESET, 1, NULL);
63
+}
64
+
65
+
66
+void u8g_SetAddress(u8g_t *u8g, u8g_dev_t *dev, uint8_t address)
67
+{
68
+  dev->com_fn(u8g, U8G_COM_MSG_ADDRESS, address, NULL);
69
+}
70
+
71
+uint8_t u8g_WriteByte(u8g_t *u8g, u8g_dev_t *dev, uint8_t val)
72
+{
73
+  return dev->com_fn(u8g, U8G_COM_MSG_WRITE_BYTE, val, NULL);
74
+}
75
+
76
+uint8_t u8g_WriteSequence(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, uint8_t *seq)
77
+{
78
+  return dev->com_fn(u8g, U8G_COM_MSG_WRITE_SEQ, cnt, seq);
79
+}
80
+
81
+uint8_t u8g_WriteSequenceP(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, const uint8_t *seq)
82
+{
83
+  return dev->com_fn(u8g, U8G_COM_MSG_WRITE_SEQ_P, cnt, (void *)seq);
84
+}
85
+
86
+/*
87
+  sequence := { direct_value | escape_sequence }
88
+  direct_value := 0..254
89
+  escape_sequence := value_255 | sequence_end | delay | adr | cs | not_used 
90
+  value_255 := 255 255
91
+  sequence_end = 255 254
92
+  delay := 255 0..127
93
+  adr := 255 0x0e0 .. 0x0ef 
94
+  cs := 255 0x0d0 .. 0x0df 
95
+  not_used := 255 101..254
96
+
97
+#define U8G_ESC_DLY(x) 255, ((x) & 0x7f)
98
+#define U8G_ESC_CS(x) 255, (0xd0 | ((x)&0x0f))
99
+#define U8G_ESC_ADR(x) 255, (0xe0 | ((x)&0x0f))
100
+#define U8G_ESC_VCC(x) 255, (0xbe | ((x)&0x01))
101
+#define U8G_ESC_END 255, 254
102
+#define U8G_ESC_255 255, 255
103
+#define U8G_ESC_RST(x) 255, (0xc0 | ((x)&0x0f))
104
+
105
+*/
106
+uint8_t u8g_WriteEscSeqP(u8g_t *u8g, u8g_dev_t *dev, const uint8_t *esc_seq)
107
+{
108
+  uint8_t is_escape = 0;
109
+  uint8_t value;
110
+  for(;;)
111
+  {
112
+    value = u8g_pgm_read(esc_seq);
113
+    if ( is_escape == 0 )
114
+    {
115
+      if ( value != 255 )
116
+      {
117
+        if ( u8g_WriteByte(u8g, dev, value) == 0 )
118
+          return 0;
119
+      }
120
+      else
121
+      {
122
+        is_escape = 1;
123
+      }
124
+    }
125
+    else
126
+    {
127
+      if ( value == 255 )
128
+      {
129
+        if ( u8g_WriteByte(u8g, dev, value) == 0 )
130
+          return 0;
131
+      }
132
+      else if ( value == 254 )
133
+      {
134
+        break;
135
+      }
136
+      else if ( value >= 0x0f0 )
137
+      {
138
+        /* not yet used, do nothing */
139
+      }
140
+      else if ( value >= 0xe0  )
141
+      {
142
+        u8g_SetAddress(u8g, dev, value & 0x0f);
143
+      }
144
+      else if ( value >= 0xd0 )
145
+      {
146
+        u8g_SetChipSelect(u8g, dev, value & 0x0f);
147
+      }
148
+      else if ( value >= 0xc0 )
149
+      {
150
+        u8g_SetResetLow(u8g, dev);
151
+        value &= 0x0f;
152
+        value <<= 4;
153
+        value+=2;
154
+        u8g_Delay(value);
155
+        u8g_SetResetHigh(u8g, dev);
156
+        u8g_Delay(value);
157
+      }
158
+      else if ( value >= 0xbe )
159
+      {
160
+	/* not yet implemented */
161
+        /* u8g_SetVCC(u8g, dev, value & 0x01); */
162
+      }
163
+      else if ( value <= 127 )
164
+      {
165
+        u8g_Delay(value);
166
+      }
167
+      is_escape = 0;
168
+    }
169
+    esc_seq++;
170
+  }
171
+  return 1;
172
+}
173
+

+ 94
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_api_16gr.c View File

@@ -0,0 +1,94 @@
1
+/*
2
+
3
+  u8g_com_api_16gr.c
4
+  
5
+  Extension of the com api for devices with 16 graylevels (4 bit per pixel).
6
+  This should fit to the 8h and 16h architectures (pb8v1, pb8v2, pb16v1, pb16v2), 
7
+  mainly intended for SSD OLEDs
8
+
9
+  Universal 8bit Graphics Library
10
+  
11
+  Copyright (c) 2011, olikraus@gmail.com
12
+  All rights reserved.
13
+
14
+  Redistribution and use in source and binary forms, with or without modification, 
15
+  are permitted provided that the following conditions are met:
16
+
17
+  * Redistributions of source code must retain the above copyright notice, this list 
18
+    of conditions and the following disclaimer.
19
+    
20
+  * Redistributions in binary form must reproduce the above copyright notice, this 
21
+    list of conditions and the following disclaimer in the documentation and/or other 
22
+    materials provided with the distribution.
23
+
24
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
25
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
26
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
27
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
28
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
29
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
30
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
31
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
32
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
33
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
34
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
35
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
36
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
37
+  
38
+  
39
+*/
40
+
41
+#include "u8g.h"
42
+
43
+/* interpret b as a monochrome bit pattern, write value 15 for high bit and value 0 for a low bit */
44
+/* topbit (msb) is sent last */
45
+/* example: b = 0x083 will send 0xff, 0x00, 0x00, 0xf0 */
46
+uint8_t u8g_WriteByteBWTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t b)
47
+{
48
+  static uint8_t buf[4];
49
+  static uint8_t map[4] = { 0, 0x00f, 0x0f0, 0x0ff };
50
+  buf [3] = map[b & 3];
51
+  b>>=2;
52
+  buf [2] = map[b & 3];
53
+  b>>=2;
54
+  buf [1] = map[b & 3];
55
+  b>>=2;
56
+  buf [0] = map[b & 3];
57
+  return dev->com_fn(u8g, U8G_COM_MSG_WRITE_SEQ, 4, buf);
58
+}
59
+
60
+uint8_t u8g_WriteSequenceBWTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, uint8_t *ptr)
61
+{
62
+  do
63
+  {
64
+    if ( u8g_WriteByteBWTo16GrDevice(u8g, dev, *ptr++) == 0 )
65
+      return 0;
66
+    cnt--;
67
+  } while( cnt != 0 );
68
+  return 1;
69
+}
70
+
71
+/* interpret b as a 4L bit pattern, write values 0x000, 0x004, 0x008, 0x00c */
72
+uint8_t u8g_WriteByte4LTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t b)
73
+{
74
+  //static uint8_t map[16] = { 0x000, 0x004, 0x008, 0x00c, 0x040, 0x044, 0x048, 0x04c, 0x080, 0x084, 0x088, 0x08c, 0x0c0, 0x0c4, 0x0c8, 0x0cc};
75
+  //static uint8_t map[16] = { 0x000, 0x004, 0x00a, 0x00f, 0x040, 0x044, 0x04a, 0x04f, 0x0a0, 0x0a4, 0x0aa, 0x0af, 0x0f0, 0x0f4, 0x0fa, 0x0ff};
76
+  static uint8_t map[16] = { 0x000, 0x040, 0x0a0, 0x0f0, 0x004, 0x044, 0x0a4, 0x0f4, 0x00a, 0x04a, 0x0aa, 0x0fa, 0x00f, 0x04f, 0x0af, 0x0ff};
77
+  uint8_t bb;
78
+  bb = b;
79
+  bb &= 15;
80
+  b>>=4;
81
+  dev->com_fn(u8g, U8G_COM_MSG_WRITE_BYTE, map[bb], NULL);
82
+  return dev->com_fn(u8g, U8G_COM_MSG_WRITE_BYTE, map[b], NULL);
83
+}
84
+
85
+uint8_t u8g_WriteSequence4LTo16GrDevice(u8g_t *u8g, u8g_dev_t *dev, uint8_t cnt, uint8_t *ptr)
86
+{
87
+  do
88
+  {
89
+    if ( u8g_WriteByte4LTo16GrDevice(u8g, dev, *ptr++) == 0 )
90
+      return 0;
91
+    cnt--;
92
+  } while( cnt != 0 );
93
+  return 1;
94
+}

+ 75
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_common.c View File

@@ -0,0 +1,75 @@
1
+/*
2
+  
3
+  u8g_com_arduino_common.c
4
+  
5
+  shared procedures for the arduino communication procedures
6
+
7
+  Universal 8bit Graphics Library
8
+  
9
+  Copyright (c) 2011, olikraus@gmail.com
10
+  All rights reserved.
11
+
12
+  Redistribution and use in source and binary forms, with or without modification, 
13
+  are permitted provided that the following conditions are met:
14
+
15
+  * Redistributions of source code must retain the above copyright notice, this list 
16
+    of conditions and the following disclaimer.
17
+    
18
+  * Redistributions in binary form must reproduce the above copyright notice, this 
19
+    list of conditions and the following disclaimer in the documentation and/or other 
20
+    materials provided with the distribution.
21
+
22
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
23
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
24
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
25
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
26
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
27
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
28
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
29
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
30
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
31
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
32
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
33
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
34
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
35
+  
36
+
37
+*/
38
+
39
+#include "u8g.h"
40
+
41
+#if defined(ARDUINO)
42
+
43
+#if ARDUINO < 100 
44
+#include <WProgram.h> 
45
+#else 
46
+#include <Arduino.h> 
47
+#endif
48
+
49
+void u8g_com_arduino_digital_write(u8g_t *u8g, uint8_t pin_index, uint8_t value)
50
+{
51
+  uint8_t pin;
52
+  pin = u8g->pin_list[pin_index];
53
+  if ( pin != U8G_PIN_NONE )
54
+    digitalWrite(pin, value);
55
+}
56
+
57
+/* this procedure does not set the RW pin */
58
+void u8g_com_arduino_assign_pin_output_high(u8g_t *u8g)
59
+{
60
+  uint8_t i;
61
+  /* skip the RW pin, which is the last pin in the list */
62
+  for( i = 0; i < U8G_PIN_LIST_LEN-1; i++ )
63
+  {
64
+    if ( u8g->pin_list[i] != U8G_PIN_NONE )
65
+    {
66
+      pinMode(u8g->pin_list[i], OUTPUT);	
67
+      digitalWrite(u8g->pin_list[i], HIGH);
68
+    }
69
+  }
70
+}
71
+
72
+
73
+#endif
74
+
75
+

+ 245
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_fast_parallel.c View File

@@ -0,0 +1,245 @@
1
+/*
2
+  
3
+  u8g_arduino_fast_parallel.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+  PIN_D0 8
35
+  PIN_D1 9
36
+  PIN_D2 10
37
+  PIN_D3 11
38
+  PIN_D4 4
39
+  PIN_D5 5
40
+  PIN_D6 6
41
+  PIN_D7 7
42
+
43
+  PIN_CS1 14
44
+  PIN_CS2 15
45
+  PIN_RW 16
46
+  PIN_DI 17
47
+  PIN_EN 18
48
+  
49
+  u8g_Init8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset)
50
+  u8g_Init8Bit(u8g, dev,  8,    9, 10, 11,   4,   5,   6,   7, 18, 14, 15, 17, 16, U8G_PIN_NONE)
51
+
52
+*/
53
+
54
+#include "u8g.h"
55
+
56
+#if  defined(ARDUINO)
57
+
58
+#if ARDUINO < 100 
59
+//#include <WProgram.h> 
60
+#include <wiring_private.h> 
61
+#include <pins_arduino.h> 
62
+#else 
63
+#include <Arduino.h> 
64
+#endif
65
+
66
+
67
+#define PIN_D0 8
68
+#define PIN_D1 9
69
+#define PIN_D2 10
70
+#define PIN_D3 11
71
+#define PIN_D4 4
72
+#define PIN_D5 5
73
+#define PIN_D6 6
74
+#define PIN_D7 7
75
+
76
+#define PIN_CS1 14
77
+#define PIN_CS2 15
78
+#define PIN_RW 16
79
+#define PIN_DI 17
80
+#define PIN_EN 18
81
+
82
+//#define PIN_RESET
83
+
84
+
85
+#if defined(__PIC32MX)
86
+/* CHIPKIT PIC32 */
87
+static volatile uint32_t *u8g_data_port[8];
88
+static uint32_t u8g_data_mask[8];
89
+#else
90
+static volatile uint8_t *u8g_data_port[8];
91
+static uint8_t u8g_data_mask[8];
92
+#endif
93
+
94
+
95
+
96
+static void u8g_com_arduino_fast_parallel_init(u8g_t *u8g)
97
+{
98
+  u8g_data_port[0] =  portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D0]));
99
+  u8g_data_mask[0] =  digitalPinToBitMask(u8g->pin_list[U8G_PI_D0]);
100
+  u8g_data_port[1] =  portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D1]));
101
+  u8g_data_mask[1] =  digitalPinToBitMask(u8g->pin_list[U8G_PI_D1]);
102
+  u8g_data_port[2] =  portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D2]));
103
+  u8g_data_mask[2] =  digitalPinToBitMask(u8g->pin_list[U8G_PI_D2]);
104
+  u8g_data_port[3] =  portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D3]));
105
+  u8g_data_mask[3] =  digitalPinToBitMask(u8g->pin_list[U8G_PI_D3]);
106
+  
107
+  u8g_data_port[4] =  portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D4]));
108
+  u8g_data_mask[4] =  digitalPinToBitMask(u8g->pin_list[U8G_PI_D4]);
109
+  u8g_data_port[5] =  portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D5]));
110
+  u8g_data_mask[5] =  digitalPinToBitMask(u8g->pin_list[U8G_PI_D5]);
111
+  u8g_data_port[6] =  portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D6]));
112
+  u8g_data_mask[6] =  digitalPinToBitMask(u8g->pin_list[U8G_PI_D6]);
113
+  u8g_data_port[7] =  portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D7]));
114
+  u8g_data_mask[7] =  digitalPinToBitMask(u8g->pin_list[U8G_PI_D7]);  
115
+}
116
+
117
+void u8g_com_arduino_fast_write_data_pin(uint8_t pin, uint8_t val)
118
+{
119
+  if ( val != 0 )
120
+    *u8g_data_port[pin] |= u8g_data_mask[pin];
121
+  else
122
+    *u8g_data_port[pin] &= ~u8g_data_mask[pin];
123
+}
124
+
125
+
126
+void u8g_com_arduino_fast_parallel_write(u8g_t *u8g, uint8_t val)
127
+{
128
+  u8g_com_arduino_fast_write_data_pin( 0, val&1 );
129
+  val >>= 1;
130
+  u8g_com_arduino_fast_write_data_pin( 1, val&1 );
131
+  val >>= 1;
132
+  u8g_com_arduino_fast_write_data_pin( 2, val&1 );
133
+  val >>= 1;
134
+  u8g_com_arduino_fast_write_data_pin( 3, val&1 );
135
+  val >>= 1;
136
+
137
+  u8g_com_arduino_fast_write_data_pin( 4, val&1 );
138
+  val >>= 1;
139
+  u8g_com_arduino_fast_write_data_pin( 5, val&1 );
140
+  val >>= 1;
141
+  u8g_com_arduino_fast_write_data_pin( 6, val&1 );
142
+  val >>= 1;
143
+  u8g_com_arduino_fast_write_data_pin( 7, val&1 );
144
+  val >>= 1;
145
+  
146
+  /* EN cycle time must be 1 micro second */
147
+  u8g_com_arduino_digital_write(u8g, U8G_PI_EN, HIGH);
148
+  u8g_MicroDelay(); /* delay by 1000ns, reference: ST7920: 140ns, SBN1661: 100ns */
149
+  u8g_com_arduino_digital_write(u8g, U8G_PI_EN, LOW);
150
+  u8g_10MicroDelay(); /* ST7920 commands: 72us */
151
+  u8g_10MicroDelay(); /* ST7920 commands: 72us */
152
+}
153
+
154
+
155
+uint8_t u8g_com_arduino_fast_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
156
+{
157
+  switch(msg)
158
+  {
159
+    case U8G_COM_MSG_INIT:
160
+      u8g_com_arduino_fast_parallel_init(u8g);
161
+      /* setup the RW pin as output and force it to low */
162
+      if ( u8g->pin_list[U8G_PI_RW] != U8G_PIN_NONE )
163
+      {
164
+        pinMode(u8g->pin_list[U8G_PI_RW], OUTPUT);
165
+        u8g_com_arduino_digital_write(u8g, U8G_PI_RW, LOW);
166
+      }
167
+      /* set all pins (except RW pin) */
168
+      u8g_com_arduino_assign_pin_output_high(u8g);
169
+      break;
170
+    case U8G_COM_MSG_STOP:
171
+      break;
172
+
173
+    case U8G_COM_MSG_CHIP_SELECT:
174
+      if ( arg_val == 0 )
175
+      {
176
+        /* disable */
177
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, HIGH);
178
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, HIGH);
179
+      }
180
+      else if ( arg_val == 1 )
181
+      {
182
+        /* enable */
183
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, LOW);
184
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, HIGH);
185
+      }
186
+      else if ( arg_val == 2 )
187
+      {
188
+        /* enable */
189
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, HIGH);
190
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, LOW);
191
+      }
192
+      else
193
+      {
194
+        /* enable */
195
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, LOW);
196
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, LOW);
197
+      }
198
+      break;
199
+    case U8G_COM_MSG_WRITE_BYTE:
200
+      u8g_com_arduino_fast_parallel_write(u8g, arg_val);
201
+      break;
202
+    case U8G_COM_MSG_WRITE_SEQ:
203
+      {
204
+        register uint8_t *ptr = arg_ptr;
205
+        while( arg_val > 0 )
206
+        {
207
+          u8g_com_arduino_fast_parallel_write(u8g, *ptr++);
208
+          arg_val--;
209
+        }
210
+      }
211
+      break;
212
+    case U8G_COM_MSG_WRITE_SEQ_P:
213
+      {
214
+        register uint8_t *ptr = arg_ptr;
215
+        while( arg_val > 0 )
216
+        {
217
+          u8g_com_arduino_fast_parallel_write(u8g, u8g_pgm_read(ptr));
218
+          ptr++;
219
+          arg_val--;
220
+        }
221
+      }
222
+      break;
223
+    case U8G_COM_MSG_ADDRESS:                     /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
224
+      u8g_com_arduino_digital_write(u8g, U8G_PI_DI, arg_val);
225
+      break;
226
+    case U8G_COM_MSG_RESET:
227
+      if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
228
+        u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val);
229
+      break;
230
+      
231
+  }
232
+  return 1;
233
+}
234
+
235
+#else
236
+
237
+
238
+uint8_t u8g_com_arduino_fast_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
239
+{
240
+  return 1;
241
+}
242
+
243
+
244
+#endif /* ARDUINO */
245
+

+ 191
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c View File

@@ -0,0 +1,191 @@
1
+/*
2
+  
3
+  u8g_com_arduino_hw_spi.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+
35
+*/
36
+
37
+#include "u8g.h"
38
+
39
+#if defined(ARDUINO)
40
+
41
+#if defined(__AVR__)
42
+
43
+#include <avr/interrupt.h>
44
+#include <avr/io.h>
45
+
46
+#if ARDUINO < 100 
47
+#include <WProgram.h> 
48
+
49
+/* fixed pins */
50
+#if defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) // Sanguino.cc board
51
+#define PIN_SCK         7
52
+#define PIN_MISO        6
53
+#define PIN_MOSI        5
54
+#define PIN_CS          4
55
+#else                                   // Arduino Board
56
+#define PIN_SCK 13
57
+#define PIN_MISO  12
58
+#define PIN_MOSI 11
59
+#define PIN_CS 10
60
+#endif // (__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
61
+
62
+#else 
63
+
64
+#include <Arduino.h> 
65
+
66
+/* use Arduino pin definitions */
67
+#define PIN_SCK SCK
68
+#define PIN_MISO  MISO
69
+#define PIN_MOSI MOSI
70
+#define PIN_CS SS
71
+
72
+#endif
73
+
74
+
75
+
76
+//static uint8_t u8g_spi_out(uint8_t data) U8G_NOINLINE;
77
+static uint8_t u8g_spi_out(uint8_t data)
78
+{
79
+  /* unsigned char x = 100; */
80
+  /* send data */
81
+  SPDR = data;
82
+  /* wait for transmission */
83
+  while (!(SPSR & (1<<SPIF))) 
84
+    ;
85
+  /* clear the SPIF flag by reading SPDR */
86
+  return  SPDR;
87
+}
88
+
89
+
90
+uint8_t u8g_com_arduino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
91
+{
92
+  switch(msg)
93
+  {
94
+    case U8G_COM_MSG_STOP:
95
+      break;
96
+    
97
+    case U8G_COM_MSG_INIT:
98
+      u8g_com_arduino_assign_pin_output_high(u8g);
99
+      pinMode(PIN_SCK, OUTPUT);
100
+      digitalWrite(PIN_SCK, LOW);
101
+      pinMode(PIN_MOSI, OUTPUT);
102
+      digitalWrite(PIN_MOSI, LOW);
103
+      /* pinMode(PIN_MISO, INPUT); */
104
+
105
+      pinMode(PIN_CS, OUTPUT);			/* system chip select for the atmega board */
106
+      digitalWrite(PIN_CS, HIGH);
107
+    
108
+
109
+
110
+      /*
111
+        SPR1 SPR0
112
+            0	0		fclk/4
113
+            0	1		fclk/16
114
+            1	0		fclk/64
115
+            1	1		fclk/128
116
+      */
117
+      SPCR = 0;
118
+      SPCR =  (1<<SPE) | (1<<MSTR)|(0<<SPR1)|(0<<SPR0)|(0<<CPOL)|(0<<CPHA);
119
+#ifdef U8G_HW_SPI_2X
120
+      SPSR = (1 << SPI2X);  /* double speed, issue 89 */
121
+#endif
122
+      
123
+      break;
124
+    
125
+    case U8G_COM_MSG_ADDRESS:                     /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
126
+      u8g_com_arduino_digital_write(u8g, U8G_PI_A0, arg_val);
127
+      break;
128
+
129
+    case U8G_COM_MSG_CHIP_SELECT:
130
+      if ( arg_val == 0 )
131
+      {
132
+        /* disable */
133
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS, HIGH);
134
+      }
135
+      else
136
+      {
137
+        /* enable */
138
+        u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, LOW);
139
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS, LOW);
140
+      }
141
+      break;
142
+      
143
+    case U8G_COM_MSG_RESET:
144
+      if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
145
+        u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val);
146
+      break;
147
+    
148
+    case U8G_COM_MSG_WRITE_BYTE:
149
+      u8g_spi_out(arg_val);
150
+      break;
151
+    
152
+    case U8G_COM_MSG_WRITE_SEQ:
153
+      {
154
+        register uint8_t *ptr = arg_ptr;
155
+        while( arg_val > 0 )
156
+        {
157
+          u8g_spi_out(*ptr++);
158
+          arg_val--;
159
+        }
160
+      }
161
+      break;
162
+    case U8G_COM_MSG_WRITE_SEQ_P:
163
+      {
164
+        register uint8_t *ptr = arg_ptr;
165
+        while( arg_val > 0 )
166
+        {
167
+          u8g_spi_out(u8g_pgm_read(ptr));
168
+          ptr++;
169
+          arg_val--;
170
+        }
171
+      }
172
+      break;
173
+  }
174
+  return 1;
175
+}
176
+
177
+/* #elif defined(__18CXX) || defined(__PIC32MX) */
178
+
179
+#else /* __AVR__ */
180
+
181
+#endif /* __AVR__ */
182
+
183
+#else /* ARDUINO */
184
+
185
+uint8_t u8g_com_arduino_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
186
+{
187
+  return 1;
188
+}
189
+
190
+#endif /* ARDUINO */
191
+

+ 221
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_no_en_parallel.c View File

@@ -0,0 +1,221 @@
1
+/*
2
+  
3
+  u8g_arduino_no_en_parallel.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2012, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+  PIN_D0 8
35
+  PIN_D1 9
36
+  PIN_D2 10
37
+  PIN_D3 11
38
+  PIN_D4 4
39
+  PIN_D5 5
40
+  PIN_D6 6
41
+  PIN_D7 7
42
+
43
+  PIN_CS1 14
44
+  PIN_CS2 15
45
+  PIN_RW 16
46
+  PIN_DI 17
47
+  PIN_EN 18
48
+  
49
+  u8g_Init8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset)
50
+  u8g_Init8Bit(u8g, dev,  8,    9, 10, 11,   4,   5,   6,   7, 18, 14, 15, 17, 16, U8G_PIN_NONE)
51
+
52
+*/
53
+
54
+#include "u8g.h"
55
+
56
+#if  defined(ARDUINO)
57
+
58
+#if ARDUINO < 100 
59
+//#include <WProgram.h> 
60
+#include <wiring_private.h> 
61
+#include <pins_arduino.h> 
62
+#else 
63
+#include <Arduino.h> 
64
+#endif
65
+
66
+//#define PIN_RESET
67
+
68
+#if defined(__PIC32MX)
69
+/* CHIPKIT PIC32 */
70
+static volatile uint32_t *u8g_data_port[8];
71
+static uint32_t u8g_data_mask[8];
72
+#else
73
+static volatile uint8_t *u8g_data_port[8];
74
+static uint8_t u8g_data_mask[8];
75
+#endif
76
+
77
+
78
+
79
+static void u8g_com_arduino_no_en_parallel_init(u8g_t *u8g)
80
+{
81
+  u8g_data_port[0] =  portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D0]));
82
+  u8g_data_mask[0] =  digitalPinToBitMask(u8g->pin_list[U8G_PI_D0]);
83
+  u8g_data_port[1] =  portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D1]));
84
+  u8g_data_mask[1] =  digitalPinToBitMask(u8g->pin_list[U8G_PI_D1]);
85
+  u8g_data_port[2] =  portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D2]));
86
+  u8g_data_mask[2] =  digitalPinToBitMask(u8g->pin_list[U8G_PI_D2]);
87
+  u8g_data_port[3] =  portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D3]));
88
+  u8g_data_mask[3] =  digitalPinToBitMask(u8g->pin_list[U8G_PI_D3]);
89
+  
90
+  u8g_data_port[4] =  portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D4]));
91
+  u8g_data_mask[4] =  digitalPinToBitMask(u8g->pin_list[U8G_PI_D4]);
92
+  u8g_data_port[5] =  portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D5]));
93
+  u8g_data_mask[5] =  digitalPinToBitMask(u8g->pin_list[U8G_PI_D5]);
94
+  u8g_data_port[6] =  portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D6]));
95
+  u8g_data_mask[6] =  digitalPinToBitMask(u8g->pin_list[U8G_PI_D6]);
96
+  u8g_data_port[7] =  portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D7]));
97
+  u8g_data_mask[7] =  digitalPinToBitMask(u8g->pin_list[U8G_PI_D7]);  
98
+}
99
+
100
+void u8g_com_arduino_no_en_write_data_pin(uint8_t pin, uint8_t val)
101
+{
102
+  if ( val != 0 )
103
+    *u8g_data_port[pin] |= u8g_data_mask[pin];
104
+  else
105
+    *u8g_data_port[pin] &= ~u8g_data_mask[pin];
106
+}
107
+
108
+
109
+void u8g_com_arduino_no_en_parallel_write(u8g_t *u8g, uint8_t val)
110
+{
111
+  u8g_com_arduino_no_en_write_data_pin( 0, val&1 );
112
+  val >>= 1;
113
+  u8g_com_arduino_no_en_write_data_pin( 1, val&1 );
114
+  val >>= 1;
115
+  u8g_com_arduino_no_en_write_data_pin( 2, val&1 );
116
+  val >>= 1;
117
+  u8g_com_arduino_no_en_write_data_pin( 3, val&1 );
118
+  val >>= 1;
119
+
120
+  u8g_com_arduino_no_en_write_data_pin( 4, val&1 );
121
+  val >>= 1;
122
+  u8g_com_arduino_no_en_write_data_pin( 5, val&1 );
123
+  val >>= 1;
124
+  u8g_com_arduino_no_en_write_data_pin( 6, val&1 );
125
+  val >>= 1;
126
+  u8g_com_arduino_no_en_write_data_pin( 7, val&1 );
127
+  val >>= 1;
128
+  
129
+  /* EN cycle time must be 1 micro second, digitalWrite is slow enough to do this */
130
+  if ( u8g->pin_list[U8G_PI_CS_STATE] == 1 )
131
+  {
132
+    u8g_MicroDelay();
133
+    u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, HIGH);
134
+    u8g_MicroDelay();
135
+    u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, LOW);
136
+    u8g_MicroDelay();
137
+  }
138
+  else if ( u8g->pin_list[U8G_PI_CS_STATE] == 2 )
139
+  {
140
+    u8g_MicroDelay();
141
+    u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, HIGH);
142
+    u8g_MicroDelay();
143
+    u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, LOW);
144
+    u8g_MicroDelay();
145
+  }
146
+}
147
+
148
+
149
+uint8_t u8g_com_arduino_no_en_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
150
+{
151
+  switch(msg)
152
+  {
153
+    case U8G_COM_MSG_INIT:
154
+      u8g_com_arduino_no_en_parallel_init(u8g);
155
+      /* setup the RW pin as output and force it to low */
156
+      if ( u8g->pin_list[U8G_PI_RW] != U8G_PIN_NONE )
157
+      {
158
+        pinMode(u8g->pin_list[U8G_PI_RW], OUTPUT);
159
+        u8g_com_arduino_digital_write(u8g, U8G_PI_RW, LOW);
160
+      }
161
+      /* set all pins (except RW pin) */
162
+      u8g_com_arduino_assign_pin_output_high(u8g);
163
+      break;
164
+    case U8G_COM_MSG_STOP:
165
+      break;
166
+
167
+    case U8G_COM_MSG_CHIP_SELECT:
168
+      /*
169
+	0: nothing selected
170
+	1: CS1 will be used as enable line
171
+        2: CS2 will be used as enable line
172
+        this will be used in the u8g_com_arduino_no_en_parallel_write() procedure
173
+      */
174
+      u8g->pin_list[U8G_PI_CS_STATE] = arg_val;
175
+      break;
176
+    case U8G_COM_MSG_WRITE_BYTE:
177
+      u8g_com_arduino_no_en_parallel_write(u8g, arg_val);
178
+      break;
179
+    case U8G_COM_MSG_WRITE_SEQ:
180
+      {
181
+        register uint8_t *ptr = arg_ptr;
182
+        while( arg_val > 0 )
183
+        {
184
+          u8g_com_arduino_no_en_parallel_write(u8g, *ptr++);
185
+          arg_val--;
186
+        }
187
+      }
188
+      break;
189
+    case U8G_COM_MSG_WRITE_SEQ_P:
190
+      {
191
+        register uint8_t *ptr = arg_ptr;
192
+        while( arg_val > 0 )
193
+        {
194
+          u8g_com_arduino_no_en_parallel_write(u8g, u8g_pgm_read(ptr));
195
+          ptr++;
196
+          arg_val--;
197
+        }
198
+      }
199
+      break;
200
+    case U8G_COM_MSG_ADDRESS:                     /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
201
+      u8g_com_arduino_digital_write(u8g, U8G_PI_DI, arg_val);
202
+      break;
203
+    case U8G_COM_MSG_RESET:
204
+      if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
205
+        u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val);
206
+      break;
207
+  }
208
+  return 1;
209
+}
210
+
211
+#else
212
+
213
+
214
+uint8_t u8g_com_arduino_no_en_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
215
+{
216
+  return 1;
217
+}
218
+
219
+
220
+#endif /* ARDUINO */
221
+

+ 187
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_parallel.c View File

@@ -0,0 +1,187 @@
1
+/*
2
+  
3
+  u8g_arduino_parallel.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+
35
+  PIN_D0 8
36
+  PIN_D1 9
37
+  PIN_D2 10
38
+  PIN_D3 11
39
+  PIN_D4 4
40
+  PIN_D5 5
41
+  PIN_D6 6
42
+  PIN_D7 7
43
+
44
+  PIN_CS1 14
45
+  PIN_CS2 15
46
+  PIN_RW 16
47
+  PIN_DI 17
48
+  PIN_EN 18
49
+  
50
+  u8g_Init8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset)
51
+  u8g_Init8Bit(u8g, dev,  8,    9, 10, 11,   4,   5,   6,   7, 18, 14, 15, 17, 16, U8G_PIN_NONE)
52
+
53
+*/
54
+
55
+#include "u8g.h"
56
+
57
+
58
+#if  defined(ARDUINO)
59
+
60
+#if ARDUINO < 100 
61
+#include <WProgram.h> 
62
+#else 
63
+#include <Arduino.h> 
64
+#endif
65
+
66
+
67
+
68
+
69
+
70
+
71
+void u8g_com_arduino_parallel_write(u8g_t *u8g, uint8_t val)
72
+{
73
+  u8g_com_arduino_digital_write(u8g, U8G_PI_D0, val&1);
74
+  val >>= 1;
75
+  u8g_com_arduino_digital_write(u8g, U8G_PI_D1, val&1);
76
+  val >>= 1;
77
+  u8g_com_arduino_digital_write(u8g, U8G_PI_D2, val&1);
78
+  val >>= 1;
79
+  u8g_com_arduino_digital_write(u8g, U8G_PI_D3, val&1);
80
+  val >>= 1;
81
+  u8g_com_arduino_digital_write(u8g, U8G_PI_D4, val&1);
82
+  val >>= 1;
83
+  u8g_com_arduino_digital_write(u8g, U8G_PI_D5, val&1);
84
+  val >>= 1;
85
+  u8g_com_arduino_digital_write(u8g, U8G_PI_D6, val&1);
86
+  val >>= 1;
87
+  u8g_com_arduino_digital_write(u8g, U8G_PI_D7, val&1);
88
+  
89
+  /* EN cycle time must be 1 micro second, digitalWrite is slow enough to do this */
90
+  //u8g_Delay(1);
91
+  u8g_com_arduino_digital_write(u8g, U8G_PI_EN, HIGH);
92
+  //u8g_Delay(1);
93
+  u8g_MicroDelay(); /* delay by 1000ns, reference: ST7920: 140ns, SBN1661: 100ns */
94
+  u8g_com_arduino_digital_write(u8g, U8G_PI_EN, LOW);
95
+  u8g_10MicroDelay(); /* ST7920 commands: 72us */
96
+  //u8g_Delay(2);
97
+}
98
+
99
+
100
+uint8_t u8g_com_arduino_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
101
+{
102
+  switch(msg)
103
+  {
104
+    case U8G_COM_MSG_INIT:
105
+      /* setup the RW pin as output and force it to low */
106
+      if ( u8g->pin_list[U8G_PI_RW] != U8G_PIN_NONE )
107
+      {
108
+        pinMode(u8g->pin_list[U8G_PI_RW], OUTPUT);
109
+        u8g_com_arduino_digital_write(u8g, U8G_PI_RW, LOW);
110
+      }
111
+      /* set all pins (except RW pin) */
112
+      u8g_com_arduino_assign_pin_output_high(u8g);
113
+      break;
114
+    case U8G_COM_MSG_STOP:
115
+      break;
116
+    case U8G_COM_MSG_CHIP_SELECT:
117
+      if ( arg_val == 0 )
118
+      {
119
+        /* disable */
120
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, HIGH);
121
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, HIGH);
122
+      }
123
+      else if ( arg_val == 1 )
124
+      {
125
+        /* enable */
126
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, LOW);
127
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, HIGH);
128
+      }
129
+      else if ( arg_val == 2 )
130
+      {
131
+        /* enable */
132
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, HIGH);
133
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, LOW);
134
+      }
135
+      else
136
+      {
137
+        /* enable */
138
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, LOW);
139
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, LOW);
140
+      }
141
+      break;
142
+    case U8G_COM_MSG_WRITE_BYTE:
143
+      u8g_com_arduino_parallel_write(u8g, arg_val);
144
+      break;
145
+    case U8G_COM_MSG_WRITE_SEQ:
146
+      {
147
+        register uint8_t *ptr = arg_ptr;
148
+        while( arg_val > 0 )
149
+        {
150
+          u8g_com_arduino_parallel_write(u8g, *ptr++);
151
+          arg_val--;
152
+        }
153
+      }
154
+      break;
155
+    case U8G_COM_MSG_WRITE_SEQ_P:
156
+      {
157
+        register uint8_t *ptr = arg_ptr;
158
+        while( arg_val > 0 )
159
+        {
160
+          u8g_com_arduino_parallel_write(u8g, u8g_pgm_read(ptr));
161
+          ptr++;
162
+          arg_val--;
163
+        }
164
+      }
165
+      break;
166
+    case U8G_COM_MSG_ADDRESS:                     /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
167
+      u8g_com_arduino_digital_write(u8g, U8G_PI_DI, arg_val);
168
+      break;
169
+    case U8G_COM_MSG_RESET:
170
+      if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
171
+        u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val);
172
+      break;
173
+      
174
+  }
175
+  return 1;
176
+}
177
+
178
+#else
179
+
180
+
181
+uint8_t u8g_com_arduino_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
182
+{
183
+  return 1;
184
+}
185
+
186
+#endif /* ARDUINO */
187
+

+ 168
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_port_d_wr.c View File

@@ -0,0 +1,168 @@
1
+/*
2
+  
3
+  u8g_arduino_port_d_wr.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+
35
+  Assumes PORTD for 8 bit data transfer.
36
+  EN is assumed to be a low active write signal (WR)
37
+
38
+  ILI9325D_320x240 from iteadstudio.com
39
+  RS=19, WR=18, CS=17, RST=16
40
+
41
+  
42
+  u8g_Init8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset)
43
+  u8g_Init8Bit(u8g, dev,  8,    9, 10, 11,   4,   5,   6,   7, 18, 14, 15, 17, 16, U8G_PIN_NONE)
44
+
45
+*/
46
+
47
+#include "u8g.h"
48
+
49
+
50
+#if  defined(ARDUINO) && defined(PORTD)
51
+
52
+#if ARDUINO < 100 
53
+#include <WProgram.h> 
54
+#else 
55
+#include <Arduino.h> 
56
+#endif
57
+
58
+
59
+
60
+
61
+
62
+
63
+static void u8g_com_arduino_port_d_8bit_wr(u8g_t *u8g, uint8_t val)
64
+{
65
+  PORTD = val;
66
+  
67
+  /* WR cycle time must be 1 micro second, digitalWrite is slow enough to do this */
68
+  u8g_com_arduino_digital_write(u8g, U8G_PI_EN, LOW);
69
+  u8g_com_arduino_digital_write(u8g, U8G_PI_EN, HIGH);
70
+}
71
+
72
+
73
+uint8_t u8g_com_arduino_port_d_wr_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
74
+{
75
+
76
+  switch(msg)
77
+  {
78
+    case U8G_COM_MSG_INIT:
79
+
80
+#ifdef UCSR0B
81
+      UCSR0B = 0;  // disable USART 0
82
+#endif
83
+      DDRD = 0x0ff;
84
+      PORTD = 0x0ff;
85
+
86
+      /* setup the RW pin as output and force it to low */
87
+      if ( u8g->pin_list[U8G_PI_RW] != U8G_PIN_NONE )
88
+      {
89
+        pinMode(u8g->pin_list[U8G_PI_RW], OUTPUT);
90
+        u8g_com_arduino_digital_write(u8g, U8G_PI_RW, HIGH);
91
+      }
92
+      /* set all pins (except RW pin) */
93
+      u8g_com_arduino_assign_pin_output_high(u8g);
94
+      u8g_com_arduino_digital_write(u8g, U8G_PI_EN, HIGH);
95
+      break;
96
+    case U8G_COM_MSG_STOP:
97
+      break;
98
+    case U8G_COM_MSG_CHIP_SELECT:
99
+      if ( arg_val == 0 )
100
+      {
101
+        /* disable */
102
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, HIGH);
103
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, HIGH);
104
+      }
105
+      else if ( arg_val == 1 )
106
+      {
107
+        /* enable */
108
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, LOW);
109
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, HIGH);
110
+      }
111
+      else if ( arg_val == 2 )
112
+      {
113
+        /* enable */
114
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, HIGH);
115
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, LOW);
116
+      }
117
+      else
118
+      {
119
+        /* enable */
120
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS1, LOW);
121
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS2, LOW);
122
+      }
123
+      break;
124
+    case U8G_COM_MSG_WRITE_BYTE:
125
+      u8g_com_arduino_port_d_8bit_wr(u8g, arg_val);
126
+      break;
127
+    case U8G_COM_MSG_WRITE_SEQ:
128
+      {
129
+        register uint8_t *ptr = arg_ptr;
130
+        while( arg_val > 0 )
131
+        {
132
+          u8g_com_arduino_port_d_8bit_wr(u8g, *ptr++);
133
+          arg_val--;
134
+        }
135
+      }
136
+      break;
137
+    case U8G_COM_MSG_WRITE_SEQ_P:
138
+      {
139
+        register uint8_t *ptr = arg_ptr;
140
+        while( arg_val > 0 )
141
+        {
142
+          u8g_com_arduino_port_d_8bit_wr(u8g, u8g_pgm_read(ptr));
143
+          ptr++;
144
+          arg_val--;
145
+        }
146
+      }
147
+      break;
148
+    case U8G_COM_MSG_ADDRESS:                     /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
149
+      u8g_com_arduino_digital_write(u8g, U8G_PI_DI, arg_val);
150
+      break;
151
+    case U8G_COM_MSG_RESET:
152
+      if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
153
+        u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val);
154
+      break;
155
+  }
156
+  return 1;
157
+}
158
+
159
+#else
160
+
161
+
162
+uint8_t u8g_com_arduino_port_d_wr_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
163
+{
164
+  return 1;
165
+}
166
+
167
+#endif /* ARDUINO && PORTD */
168
+

+ 201
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_ssd_i2c.c View File

@@ -0,0 +1,201 @@
1
+/*
2
+  
3
+  u8g_com_arduino_ssd_i2c.c
4
+
5
+  com interface for arduino (AND atmega) and the SSDxxxx chip (SOLOMON) variant 
6
+  I2C protocol 
7
+  
8
+  ToDo: Rename this to u8g_com_avr_ssd_i2c.c
9
+
10
+  Universal 8bit Graphics Library
11
+  
12
+  Copyright (c) 2012, olikraus@gmail.com
13
+  All rights reserved.
14
+
15
+  Redistribution and use in source and binary forms, with or without modification, 
16
+  are permitted provided that the following conditions are met:
17
+
18
+  * Redistributions of source code must retain the above copyright notice, this list 
19
+    of conditions and the following disclaimer.
20
+    
21
+  * Redistributions in binary form must reproduce the above copyright notice, this 
22
+    list of conditions and the following disclaimer in the documentation and/or other 
23
+    materials provided with the distribution.
24
+
25
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
26
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
27
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
28
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
29
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
30
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
31
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
32
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
33
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
34
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
35
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
36
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
37
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
38
+  
39
+  Special pin usage:
40
+    U8G_PI_I2C_OPTION	additional options
41
+    U8G_PI_A0_STATE	used to store the last value of the command/data register selection
42
+    U8G_PI_SET_A0		1: Signal request to update I2C device with new A0_STATE, 0: Do nothing, A0_STATE matches I2C device
43
+    U8G_PI_SCL		clock line (NOT USED)
44
+    U8G_PI_SDA		data line (NOT USED)
45
+    
46
+    U8G_PI_RESET		reset line (currently disabled, see below)
47
+
48
+  Protocol:
49
+    SLA, Cmd/Data Selection, Arguments
50
+    The command/data register is selected by a special instruction byte, which is sent after SLA
51
+    
52
+    The continue bit is always 0 so that a (re)start is equired for the change from cmd to/data mode
53
+*/
54
+
55
+#include "u8g.h"
56
+
57
+#define I2C_SLA		(0x3c*2)
58
+//#define I2C_CMD_MODE	0x080
59
+#define I2C_CMD_MODE	0x000
60
+#define I2C_DATA_MODE	0x040
61
+
62
+
63
+uint8_t u8g_com_arduino_ssd_start_sequence(u8g_t *u8g)
64
+{
65
+  /* are we requested to set the a0 state? */
66
+  if ( u8g->pin_list[U8G_PI_SET_A0] == 0 )
67
+    return 1;	
68
+  
69
+  /* setup bus, might be a repeated start */
70
+  if ( u8g_i2c_start(I2C_SLA) == 0 )
71
+    return 0;
72
+  if ( u8g->pin_list[U8G_PI_A0_STATE] == 0 )
73
+  {
74
+    if ( u8g_i2c_send_byte(I2C_CMD_MODE) == 0 )
75
+      return 0;
76
+  }
77
+  else
78
+  {
79
+    if ( u8g_i2c_send_byte(I2C_DATA_MODE) == 0 )
80
+      return 0;
81
+  }
82
+  
83
+  
84
+  u8g->pin_list[U8G_PI_SET_A0] = 0;
85
+  return 1;
86
+}
87
+
88
+uint8_t u8g_com_arduino_ssd_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
89
+{
90
+  switch(msg)
91
+  {
92
+    case U8G_COM_MSG_INIT:
93
+      //u8g_com_arduino_digital_write(u8g, U8G_PI_SCL, HIGH);
94
+      //u8g_com_arduino_digital_write(u8g, U8G_PI_SDA, HIGH);
95
+      //u8g->pin_list[U8G_PI_A0_STATE] = 0;       /* inital RS state: unknown mode */
96
+    
97
+      u8g_i2c_init(u8g->pin_list[U8G_PI_I2C_OPTION]);
98
+
99
+      break;
100
+    
101
+    case U8G_COM_MSG_STOP:
102
+      break;
103
+
104
+    case U8G_COM_MSG_RESET:
105
+      /* Currently disabled, but it could be enable. Previous restrictions have been removed */
106
+      /* u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val); */
107
+      break;
108
+      
109
+    case U8G_COM_MSG_CHIP_SELECT:
110
+      u8g->pin_list[U8G_PI_A0_STATE] = 0;
111
+      u8g->pin_list[U8G_PI_SET_A0] = 1;		/* force a0 to set again, also forces start condition */
112
+      if ( arg_val == 0 )
113
+      {
114
+        /* disable chip, send stop condition */
115
+	u8g_i2c_stop();
116
+     }
117
+      else
118
+      {
119
+        /* enable, do nothing: any byte writing will trigger the i2c start */
120
+      }
121
+      break;
122
+
123
+    case U8G_COM_MSG_WRITE_BYTE:
124
+      //u8g->pin_list[U8G_PI_SET_A0] = 1;
125
+      if ( u8g_com_arduino_ssd_start_sequence(u8g) == 0 )
126
+	return u8g_i2c_stop(), 0;
127
+      if ( u8g_i2c_send_byte(arg_val) == 0 )
128
+	return u8g_i2c_stop(), 0;
129
+      // u8g_i2c_stop();
130
+      break;
131
+    
132
+    case U8G_COM_MSG_WRITE_SEQ:
133
+      //u8g->pin_list[U8G_PI_SET_A0] = 1;
134
+      if ( u8g_com_arduino_ssd_start_sequence(u8g) == 0 )
135
+	return u8g_i2c_stop(), 0;
136
+      {
137
+        register uint8_t *ptr = arg_ptr;
138
+        while( arg_val > 0 )
139
+        {
140
+	  if ( u8g_i2c_send_byte(*ptr++) == 0 )
141
+	    return u8g_i2c_stop(), 0;
142
+          arg_val--;
143
+        }
144
+      }
145
+      // u8g_i2c_stop();
146
+      break;
147
+
148
+    case U8G_COM_MSG_WRITE_SEQ_P:
149
+      //u8g->pin_list[U8G_PI_SET_A0] = 1;
150
+      if ( u8g_com_arduino_ssd_start_sequence(u8g) == 0 )
151
+	return u8g_i2c_stop(), 0;
152
+      {
153
+        register uint8_t *ptr = arg_ptr;
154
+        while( arg_val > 0 )
155
+        {
156
+	  if ( u8g_i2c_send_byte(u8g_pgm_read(ptr)) == 0 )
157
+	    return 0;
158
+          ptr++;
159
+          arg_val--;
160
+        }
161
+      }
162
+      // u8g_i2c_stop();
163
+      break;
164
+      
165
+    case U8G_COM_MSG_ADDRESS:                     /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
166
+      u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
167
+      u8g->pin_list[U8G_PI_SET_A0] = 1;		/* force a0 to set again */
168
+    
169
+#ifdef OLD_CODE    
170
+      if ( i2c_state != 0 )
171
+      {
172
+	u8g_i2c_stop();
173
+	i2c_state = 0;
174
+      }
175
+
176
+      if ( u8g_com_arduino_ssd_start_sequence(arg_val) == 0 )
177
+	return 0;
178
+    
179
+      /* setup bus, might be a repeated start */
180
+      /*
181
+      if ( u8g_i2c_start(I2C_SLA) == 0 )
182
+	return 0;
183
+      if ( arg_val == 0 )
184
+      {
185
+	i2c_state = 1;
186
+	
187
+	if ( u8g_i2c_send_byte(I2C_CMD_MODE) == 0 )
188
+	  return 0;
189
+      }
190
+      else
191
+      {
192
+	i2c_state = 2;
193
+	if ( u8g_i2c_send_byte(I2C_DATA_MODE) == 0 )
194
+	  return 0;
195
+      }
196
+      */
197
+#endif
198
+      break;
199
+  }
200
+  return 1;
201
+}

+ 220
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_st7920_hw_spi.c View File

@@ -0,0 +1,220 @@
1
+/*
2
+  
3
+  u8g_com_arduino_st7920_hw_spi.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+
34
+  A special HW SPI interface for ST7920 controller
35
+
36
+*/
37
+
38
+#include "u8g.h"
39
+
40
+#if defined(ARDUINO)
41
+
42
+#if ARDUINO < 100 
43
+#include <WProgram.h>    
44
+#include "wiring_private.h"
45
+#include "pins_arduino.h"
46
+
47
+#else 
48
+#include <Arduino.h> 
49
+#include "wiring_private.h"
50
+#endif
51
+
52
+#if defined(__AVR__)
53
+#define U8G_ARDUINO_ATMEGA_HW_SPI
54
+
55
+/* remove the definition for attiny */
56
+#if __AVR_ARCH__ == 2
57
+#undef U8G_ATMEGA_HW_SPI
58
+#endif
59
+#if __AVR_ARCH__ == 25
60
+#undef U8G_ATMEGA_HW_SPI
61
+#endif
62
+
63
+#endif
64
+
65
+
66
+#if defined(U8G_ARDUINO_ATMEGA_HW_SPI)
67
+
68
+#include <avr/interrupt.h>
69
+#include <avr/io.h>
70
+
71
+static uint8_t u8g_arduino_st7920_hw_spi_shift_out(u8g_t *u8g, uint8_t val) U8G_NOINLINE;
72
+static uint8_t u8g_arduino_st7920_hw_spi_shift_out(u8g_t *u8g, uint8_t val)
73
+{
74
+  /* send data */
75
+  SPDR = val;
76
+  /* wait for transmission */
77
+  while (!(SPSR & (1<<SPIF))) 
78
+    ;
79
+  /* clear the SPIF flag by reading SPDR */
80
+  return  SPDR;
81
+}
82
+
83
+
84
+static void u8g_com_arduino_st7920_write_byte_hw_spi(u8g_t *u8g, uint8_t rs, uint8_t val) U8G_NOINLINE;
85
+static void u8g_com_arduino_st7920_write_byte_hw_spi(u8g_t *u8g, uint8_t rs, uint8_t val)
86
+{
87
+  uint8_t i;
88
+
89
+  if ( rs == 0 )
90
+  {
91
+    /* command */
92
+    u8g_arduino_st7920_hw_spi_shift_out(u8g, 0x0f8);
93
+  }
94
+  else if ( rs == 1 )
95
+  {
96
+    /* data */
97
+    u8g_arduino_st7920_hw_spi_shift_out(u8g, 0x0fa);
98
+  }
99
+  else
100
+  {
101
+    /* do nothing, keep same state */
102
+  }
103
+  
104
+  u8g_arduino_st7920_hw_spi_shift_out(u8g, val & 0x0f0);
105
+  u8g_arduino_st7920_hw_spi_shift_out(u8g, val << 4);
106
+
107
+  for( i = 0; i < 4; i++ )
108
+    u8g_10MicroDelay();
109
+}
110
+
111
+
112
+uint8_t u8g_com_arduino_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
113
+{
114
+  switch(msg)
115
+  {
116
+    case U8G_COM_MSG_INIT:
117
+      u8g_com_arduino_assign_pin_output_high(u8g);
118
+      u8g_com_arduino_digital_write(u8g, U8G_PI_CS, LOW);
119
+      
120
+      DDRB |= _BV(3);          /* D0, MOSI */
121
+      DDRB |= _BV(5);          /* SCK */
122
+      DDRB |= _BV(2);		/* slave select */
123
+    
124
+      PORTB &= ~_BV(3);        /* D0, MOSI = 0 */
125
+      PORTB &= ~_BV(5);        /* SCK = 0 */
126
+
127
+      /*
128
+        SPR1 SPR0
129
+            0	0		fclk/4
130
+            0	1		fclk/16 
131
+            1	0		fclk/64  
132
+            1	1		fclk/128
133
+      */
134
+      SPCR = 0;
135
+      
136
+      /* 20 Dez 2012: set CPOL and CPHA to 1 !!! */
137
+      SPCR =  (1<<SPE) | (1<<MSTR)|(0<<SPR1)|(0<<SPR0)|(1<<CPOL)|(1<<CPHA);
138
+#ifdef U8G_HW_SPI_2X
139
+      SPSR = (1 << SPI2X);  /* double speed, issue 89 */
140
+#endif
141
+      u8g->pin_list[U8G_PI_A0_STATE] = 0;       /* inital RS state: command mode */
142
+      break;
143
+    
144
+    case U8G_COM_MSG_STOP:
145
+      break;
146
+
147
+    case U8G_COM_MSG_RESET:
148
+      if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
149
+	u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val);
150
+      break;
151
+      
152
+    case U8G_COM_MSG_CHIP_SELECT:
153
+      if ( arg_val == 0 )
154
+      {
155
+        /* disable, note: the st7920 has an active high chip select */
156
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS, LOW);
157
+      }
158
+      else
159
+      {
160
+        /* enable */
161
+        //u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, LOW);
162
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS, HIGH);
163
+      }
164
+      break;
165
+
166
+    case U8G_COM_MSG_WRITE_BYTE:
167
+      u8g_com_arduino_st7920_write_byte_hw_spi(u8g,  u8g->pin_list[U8G_PI_A0_STATE], arg_val);
168
+      // u8g->pin_list[U8G_PI_A0_STATE] = 2; 
169
+      //u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], arg_val);
170
+      break;
171
+    
172
+    case U8G_COM_MSG_WRITE_SEQ:
173
+      {
174
+        register uint8_t *ptr = arg_ptr;
175
+        while( arg_val > 0 )
176
+        {
177
+          u8g_com_arduino_st7920_write_byte_hw_spi(u8g, u8g->pin_list[U8G_PI_A0_STATE], *ptr++);
178
+          // u8g->pin_list[U8G_PI_A0_STATE] = 2; 
179
+          arg_val--;
180
+        }
181
+      }
182
+      break;
183
+
184
+      case U8G_COM_MSG_WRITE_SEQ_P:
185
+      {
186
+        register uint8_t *ptr = arg_ptr;
187
+        while( arg_val > 0 )
188
+        {
189
+          u8g_com_arduino_st7920_write_byte_hw_spi(u8g, u8g->pin_list[U8G_PI_A0_STATE], u8g_pgm_read(ptr) );
190
+          // u8g->pin_list[U8G_PI_A0_STATE] = 2; 
191
+          ptr++;
192
+          arg_val--;
193
+        }
194
+      }
195
+      break;
196
+      
197
+    case U8G_COM_MSG_ADDRESS:                     /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
198
+      u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
199
+      break;
200
+  }
201
+  return 1;
202
+}
203
+
204
+#else
205
+
206
+uint8_t u8g_com_arduino_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
207
+{
208
+  return 1;
209
+}
210
+#endif
211
+
212
+#else /* ARDUINO */
213
+
214
+uint8_t u8g_com_arduino_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
215
+{
216
+  return 1;
217
+}
218
+
219
+#endif /* ARDUINO */
220
+

+ 295
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_st7920_spi.c View File

@@ -0,0 +1,295 @@
1
+/*
2
+  
3
+  u8g_com_arduino_st7920_spi.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+
34
+  A special SPI interface for ST7920 controller
35
+
36
+*/
37
+
38
+#include "u8g.h"
39
+
40
+#if defined(ARDUINO)
41
+
42
+#if ARDUINO < 100 
43
+#include <WProgram.h>    
44
+#include "wiring_private.h"
45
+#include "pins_arduino.h"
46
+
47
+#else 
48
+#include <Arduino.h> 
49
+#include "wiring_private.h"
50
+#endif
51
+
52
+#if defined(__AVR__)
53
+
54
+uint8_t u8g_bitData, u8g_bitNotData;
55
+uint8_t u8g_bitClock, u8g_bitNotClock;
56
+volatile uint8_t *u8g_outData;
57
+volatile uint8_t *u8g_outClock;
58
+
59
+static void u8g_com_arduino_init_shift_out(uint8_t dataPin, uint8_t clockPin)
60
+{
61
+  u8g_outData = portOutputRegister(digitalPinToPort(dataPin));
62
+  u8g_outClock = portOutputRegister(digitalPinToPort(clockPin));
63
+  u8g_bitData = digitalPinToBitMask(dataPin);
64
+  u8g_bitClock = digitalPinToBitMask(clockPin);
65
+
66
+  u8g_bitNotClock = u8g_bitClock;
67
+  u8g_bitNotClock ^= 0x0ff;
68
+
69
+  u8g_bitNotData = u8g_bitData;
70
+  u8g_bitNotData ^= 0x0ff;
71
+}
72
+
73
+static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val) U8G_NOINLINE;
74
+static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val)
75
+{
76
+  uint8_t cnt = 8;
77
+  uint8_t bitData = u8g_bitData;
78
+  uint8_t bitNotData = u8g_bitNotData;
79
+  uint8_t bitClock = u8g_bitClock;
80
+  uint8_t bitNotClock = u8g_bitNotClock;
81
+  volatile uint8_t *outData = u8g_outData;
82
+  volatile uint8_t *outClock = u8g_outClock;
83
+  do
84
+  {
85
+    if ( val & 128 )
86
+      *outData |= bitData;
87
+    else
88
+      *outData &= bitNotData;
89
+
90
+    /*
91
+    *outClock |= bitClock;
92
+    val <<= 1;
93
+    cnt--;
94
+    *outClock &= bitNotClock;
95
+    */
96
+
97
+    val <<= 1;
98
+    *outClock &= bitNotClock;
99
+    cnt--;
100
+    // removed micro delays, because AVRs are too slow and the delay is not required
101
+    //u8g_MicroDelay();
102
+    *outClock |= bitClock;
103
+    //u8g_MicroDelay();
104
+  } while( cnt != 0 );
105
+}
106
+
107
+#elif defined(__18CXX) || defined(__PIC32MX)
108
+
109
+uint16_t dog_bitData, dog_bitNotData;
110
+uint16_t dog_bitClock, dog_bitNotClock;
111
+volatile uint32_t *dog_outData;
112
+volatile uint32_t *dog_outClock;
113
+volatile uint32_t dog_pic32_spi_tmp;
114
+
115
+static void u8g_com_arduino_init_shift_out(uint8_t dataPin, uint8_t clockPin)
116
+{
117
+  dog_outData = portOutputRegister(digitalPinToPort(dataPin));
118
+  dog_outClock = portOutputRegister(digitalPinToPort(clockPin));
119
+  dog_bitData = digitalPinToBitMask(dataPin);
120
+  dog_bitClock = digitalPinToBitMask(clockPin);
121
+
122
+  dog_bitNotClock = dog_bitClock;
123
+  dog_bitNotClock ^= 0x0ffff;
124
+
125
+  dog_bitNotData = dog_bitData;
126
+  dog_bitNotData ^= 0x0ffff;
127
+}
128
+
129
+static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val)
130
+{
131
+  uint8_t cnt = 8;
132
+  do
133
+  {
134
+    if ( val & 128 )
135
+	*dog_outData |= dog_bitData;
136
+    else
137
+	*dog_outData &= dog_bitNotData;    
138
+    val <<= 1;
139
+    //u8g_MicroDelay();
140
+    //*dog_outClock |= dog_bitClock;
141
+    *dog_outClock &= dog_bitNotClock;
142
+    cnt--;
143
+    u8g_MicroDelay();
144
+    //*dog_outClock &= dog_bitNotClock;
145
+    *dog_outClock |= dog_bitClock;
146
+    u8g_MicroDelay();
147
+    
148
+  } while( cnt != 0 );
149
+}
150
+
151
+#else
152
+
153
+/* default interface, Arduino DUE (__arm__) */
154
+
155
+uint8_t u8g_data_pin;
156
+uint8_t u8g_clock_pin;
157
+
158
+static void u8g_com_arduino_init_shift_out(uint8_t dataPin, uint8_t clockPin)
159
+{
160
+  u8g_data_pin = dataPin;
161
+  u8g_clock_pin = clockPin;
162
+}
163
+
164
+static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val)
165
+{
166
+  uint8_t cnt = 8;
167
+  do
168
+  {
169
+    if ( val & 128 )
170
+	digitalWrite(u8g_data_pin, HIGH);
171
+    else
172
+	digitalWrite(u8g_data_pin, LOW);
173
+    val <<= 1;
174
+    //u8g_MicroDelay();
175
+    digitalWrite(u8g_clock_pin, LOW);
176
+    cnt--;
177
+    u8g_MicroDelay();
178
+    digitalWrite(u8g_clock_pin, HIGH);
179
+    u8g_MicroDelay();    
180
+  } while( cnt != 0 );
181
+}
182
+
183
+#endif 
184
+
185
+
186
+
187
+
188
+static void u8g_com_arduino_st7920_write_byte(uint8_t rs, uint8_t val)
189
+{
190
+  uint8_t i;
191
+
192
+  if ( rs == 0 )
193
+  {
194
+    /* command */
195
+    u8g_com_arduino_do_shift_out_msb_first(0x0f8);
196
+  }
197
+  else if ( rs == 1 )
198
+  {
199
+    /* data */
200
+    u8g_com_arduino_do_shift_out_msb_first(0x0fa);
201
+  }
202
+  
203
+  u8g_com_arduino_do_shift_out_msb_first(val & 0x0f0);
204
+  u8g_com_arduino_do_shift_out_msb_first(val << 4);
205
+  
206
+  for( i = 0; i < 4; i++ )
207
+    u8g_10MicroDelay();
208
+    
209
+}
210
+
211
+
212
+
213
+uint8_t u8g_com_arduino_st7920_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
214
+{
215
+  switch(msg)
216
+  {
217
+    case U8G_COM_MSG_INIT:
218
+      u8g_com_arduino_assign_pin_output_high(u8g);
219
+      u8g_com_arduino_digital_write(u8g, U8G_PI_CS, LOW);
220
+      // u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, LOW);
221
+      u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, HIGH);
222
+      u8g_com_arduino_digital_write(u8g, U8G_PI_MOSI, LOW);
223
+      u8g_com_arduino_init_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK]);
224
+      u8g->pin_list[U8G_PI_A0_STATE] = 0;       /* inital RS state: command mode */
225
+      break;
226
+    
227
+    case U8G_COM_MSG_STOP:
228
+      break;
229
+
230
+    case U8G_COM_MSG_RESET:
231
+      if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
232
+	u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val);
233
+      break;
234
+      
235
+    case U8G_COM_MSG_CHIP_SELECT:
236
+      if ( arg_val == 0 )
237
+      {
238
+        /* disable, note: the st7920 has an active high chip select */
239
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS, LOW);
240
+      }
241
+      else
242
+      {
243
+        /* enable */
244
+        //u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, HIGH);
245
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS, HIGH);
246
+      }
247
+      break;
248
+
249
+    case U8G_COM_MSG_WRITE_BYTE:
250
+      u8g_com_arduino_st7920_write_byte( u8g->pin_list[U8G_PI_A0_STATE], arg_val);
251
+      //u8g->pin_list[U8G_PI_A0_STATE] = 2; 
252
+      //u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], arg_val);
253
+      break;
254
+    
255
+    case U8G_COM_MSG_WRITE_SEQ:
256
+      {
257
+        register uint8_t *ptr = arg_ptr;
258
+        while( arg_val > 0 )
259
+        {
260
+          u8g_com_arduino_st7920_write_byte(u8g->pin_list[U8G_PI_A0_STATE], *ptr++);
261
+          //u8g->pin_list[U8G_PI_A0_STATE] = 2; 
262
+          arg_val--;
263
+        }
264
+      }
265
+      break;
266
+
267
+      case U8G_COM_MSG_WRITE_SEQ_P:
268
+      {
269
+        register uint8_t *ptr = arg_ptr;
270
+        while( arg_val > 0 )
271
+        {
272
+          u8g_com_arduino_st7920_write_byte(u8g->pin_list[U8G_PI_A0_STATE], u8g_pgm_read(ptr) );
273
+          //u8g->pin_list[U8G_PI_A0_STATE] = 2; 
274
+          ptr++;
275
+          arg_val--;
276
+        }
277
+      }
278
+      break;
279
+      
280
+    case U8G_COM_MSG_ADDRESS:                     /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
281
+      u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
282
+      break;
283
+  }
284
+  return 1;
285
+}
286
+
287
+#else /* ARDUINO */
288
+
289
+uint8_t u8g_com_arduino_st7920_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
290
+{
291
+  return 1;
292
+}
293
+
294
+#endif /* ARDUINO */
295
+

+ 144
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_std_sw_spi.c View File

@@ -0,0 +1,144 @@
1
+/*
2
+  
3
+  u8g_arduino_std_sw_spi.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+
35
+*/
36
+
37
+#include "u8g.h"
38
+
39
+
40
+#if defined(ARDUINO)
41
+
42
+#if ARDUINO < 100 
43
+#include <WProgram.h>
44
+#else 
45
+#include <Arduino.h> 
46
+#endif
47
+
48
+void u8g_arduino_sw_spi_shift_out(uint8_t dataPin, uint8_t clockPin, uint8_t val)
49
+{
50
+  uint8_t i = 8;
51
+  do
52
+  {
53
+    if ( val & 128 )
54
+      digitalWrite(dataPin, HIGH);
55
+    else
56
+      digitalWrite(dataPin, LOW);
57
+    val <<= 1;
58
+    u8g_MicroDelay();		/* 23 Sep 2012 */
59
+    //delay(1);
60
+    digitalWrite(clockPin, HIGH);
61
+    u8g_MicroDelay();		/* 23 Sep 2012 */
62
+    //delay(1);
63
+    digitalWrite(clockPin, LOW);		
64
+    u8g_MicroDelay();		/* 23 Sep 2012 */
65
+    //delay(1);
66
+    i--;
67
+  } while( i != 0 );
68
+}
69
+
70
+uint8_t u8g_com_arduino_std_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
71
+{
72
+  switch(msg)
73
+  {
74
+    case U8G_COM_MSG_INIT:
75
+      u8g_com_arduino_assign_pin_output_high(u8g);
76
+      u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, LOW);
77
+      u8g_com_arduino_digital_write(u8g, U8G_PI_MOSI, LOW);
78
+      break;
79
+    
80
+    case U8G_COM_MSG_STOP:
81
+      break;
82
+
83
+    case U8G_COM_MSG_RESET:
84
+      if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
85
+        u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val);
86
+      break;
87
+      
88
+    case U8G_COM_MSG_CHIP_SELECT:
89
+      if ( arg_val == 0 )
90
+      {
91
+        /* disable */
92
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS, HIGH);
93
+      }
94
+      else
95
+      {
96
+        /* enable */
97
+        u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, LOW);
98
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS, LOW);
99
+      }
100
+      break;
101
+
102
+    case U8G_COM_MSG_WRITE_BYTE:
103
+      u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], arg_val);
104
+      break;
105
+    
106
+    case U8G_COM_MSG_WRITE_SEQ:
107
+      {
108
+        register uint8_t *ptr = arg_ptr;
109
+        while( arg_val > 0 )
110
+        {
111
+          u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], *ptr++);
112
+          arg_val--;
113
+        }
114
+      }
115
+      break;
116
+
117
+      case U8G_COM_MSG_WRITE_SEQ_P:
118
+      {
119
+        register uint8_t *ptr = arg_ptr;
120
+        while( arg_val > 0 )
121
+        {
122
+          u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], u8g_pgm_read(ptr));
123
+          ptr++;
124
+          arg_val--;
125
+        }
126
+      }
127
+      break;
128
+      
129
+    case U8G_COM_MSG_ADDRESS:                     /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
130
+      u8g_com_arduino_digital_write(u8g, U8G_PI_A0, arg_val);
131
+      break;
132
+  }
133
+  return 1;
134
+}
135
+
136
+#else /* ARDUINO */
137
+
138
+uint8_t u8g_com_arduino_std_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
139
+{
140
+  return 1;
141
+}
142
+
143
+#endif /* ARDUINO */
144
+

+ 239
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_sw_spi.c View File

@@ -0,0 +1,239 @@
1
+/*
2
+  
3
+  u8g_arduino_sw_spi.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+
35
+*/
36
+
37
+#include "u8g.h"
38
+
39
+#if defined(ARDUINO)
40
+
41
+#if ARDUINO < 100 
42
+#include <WProgram.h>    
43
+#include "wiring_private.h"
44
+#include "pins_arduino.h"
45
+
46
+#else 
47
+#include <Arduino.h> 
48
+#include "wiring_private.h"
49
+#endif
50
+
51
+#if defined(__AVR__)
52
+
53
+uint8_t u8g_bitData, u8g_bitNotData;
54
+uint8_t u8g_bitClock, u8g_bitNotClock;
55
+volatile uint8_t *u8g_outData;
56
+volatile uint8_t *u8g_outClock;
57
+
58
+static void u8g_com_arduino_init_shift_out(uint8_t dataPin, uint8_t clockPin)
59
+{
60
+  u8g_outData = portOutputRegister(digitalPinToPort(dataPin));
61
+  u8g_outClock = portOutputRegister(digitalPinToPort(clockPin));
62
+  u8g_bitData = digitalPinToBitMask(dataPin);
63
+  u8g_bitClock = digitalPinToBitMask(clockPin);
64
+
65
+  u8g_bitNotClock = u8g_bitClock;
66
+  u8g_bitNotClock ^= 0x0ff;
67
+
68
+  u8g_bitNotData = u8g_bitData;
69
+  u8g_bitNotData ^= 0x0ff;
70
+}
71
+
72
+static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val) U8G_NOINLINE;
73
+static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val)
74
+{
75
+  uint8_t cnt = 8;
76
+  uint8_t bitData = u8g_bitData;
77
+  uint8_t bitNotData = u8g_bitNotData;
78
+  uint8_t bitClock = u8g_bitClock;
79
+  uint8_t bitNotClock = u8g_bitNotClock;
80
+  volatile uint8_t *outData = u8g_outData;
81
+  volatile uint8_t *outClock = u8g_outClock;
82
+  do
83
+  {
84
+    if ( val & 128 )
85
+      *outData |= bitData;
86
+    else
87
+      *outData &= bitNotData;
88
+   
89
+    *outClock |= bitClock;
90
+    val <<= 1;
91
+    cnt--;
92
+    *outClock &= bitNotClock;
93
+  } while( cnt != 0 );
94
+}
95
+
96
+#elif defined(__18CXX) || defined(__PIC32MX)
97
+
98
+uint16_t dog_bitData, dog_bitNotData;
99
+uint16_t dog_bitClock, dog_bitNotClock;
100
+volatile uint32_t *dog_outData;
101
+volatile uint32_t *dog_outClock;
102
+volatile uint32_t dog_pic32_spi_tmp;
103
+
104
+static void u8g_com_arduino_init_shift_out(uint8_t dataPin, uint8_t clockPin)
105
+{
106
+  dog_outData = portOutputRegister(digitalPinToPort(dataPin));
107
+  dog_outClock = portOutputRegister(digitalPinToPort(clockPin));
108
+  dog_bitData = digitalPinToBitMask(dataPin);
109
+  dog_bitClock = digitalPinToBitMask(clockPin);
110
+
111
+  dog_bitNotClock = dog_bitClock;
112
+  dog_bitNotClock ^= 0x0ffff;
113
+
114
+  dog_bitNotData = dog_bitData;
115
+  dog_bitNotData ^= 0x0ffff;
116
+}
117
+
118
+static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val)
119
+{
120
+  uint8_t cnt = 8;
121
+  do
122
+  {
123
+    if ( val & 128 )
124
+	*dog_outData |= dog_bitData;
125
+    else
126
+	*dog_outData &= dog_bitNotData;    
127
+    val <<= 1;
128
+    /*
129
+	There must be some delay here. However
130
+	fetching the adress dog_outClock is enough delay, so
131
+	do not place dog_outClock in a local variable. This will
132
+	break the procedure
133
+    */
134
+    *dog_outClock |= dog_bitClock;
135
+    cnt--;
136
+    *dog_outClock &= dog_bitNotClock;
137
+    /* 
138
+	little additional delay after clk pulse, done by 3x32bit reads 
139
+	from I/O. Optimized for PIC32 with 80 MHz.
140
+    */
141
+    dog_pic32_spi_tmp = *dog_outClock;
142
+    dog_pic32_spi_tmp = *dog_outClock;
143
+    dog_pic32_spi_tmp = *dog_outClock;
144
+  } while( cnt != 0 );
145
+}
146
+
147
+#else
148
+/* empty interface */
149
+
150
+static void u8g_com_arduino_init_shift_out(uint8_t dataPin, uint8_t clockPin)
151
+{
152
+}
153
+
154
+static void u8g_com_arduino_do_shift_out_msb_first(uint8_t val)
155
+{
156
+}
157
+
158
+#endif 
159
+
160
+
161
+uint8_t u8g_com_arduino_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
162
+{
163
+  switch(msg)
164
+  {
165
+    case U8G_COM_MSG_INIT:
166
+      u8g_com_arduino_assign_pin_output_high(u8g);
167
+      u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, LOW);
168
+      u8g_com_arduino_digital_write(u8g, U8G_PI_MOSI, LOW);
169
+      u8g_com_arduino_init_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK]);
170
+      break;
171
+    
172
+    case U8G_COM_MSG_STOP:
173
+      break;
174
+
175
+    case U8G_COM_MSG_RESET:
176
+      if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
177
+        u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val);
178
+      break;
179
+      
180
+    case U8G_COM_MSG_CHIP_SELECT:
181
+      if ( arg_val == 0 )
182
+      {
183
+        /* disable */
184
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS, HIGH);
185
+      }
186
+      else
187
+      {
188
+        /* enable */
189
+        u8g_com_arduino_digital_write(u8g, U8G_PI_SCK, LOW);
190
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS, LOW);
191
+      }
192
+      break;
193
+
194
+    case U8G_COM_MSG_WRITE_BYTE:
195
+      u8g_com_arduino_do_shift_out_msb_first( arg_val );
196
+      //u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], arg_val);
197
+      break;
198
+    
199
+    case U8G_COM_MSG_WRITE_SEQ:
200
+      {
201
+        register uint8_t *ptr = arg_ptr;
202
+        while( arg_val > 0 )
203
+        {
204
+          u8g_com_arduino_do_shift_out_msb_first(*ptr++);
205
+          // u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], *ptr++);
206
+          arg_val--;
207
+        }
208
+      }
209
+      break;
210
+
211
+      case U8G_COM_MSG_WRITE_SEQ_P:
212
+      {
213
+        register uint8_t *ptr = arg_ptr;
214
+        while( arg_val > 0 )
215
+        {
216
+          u8g_com_arduino_do_shift_out_msb_first( u8g_pgm_read(ptr) );
217
+          //u8g_arduino_sw_spi_shift_out(u8g->pin_list[U8G_PI_MOSI], u8g->pin_list[U8G_PI_SCK], u8g_pgm_read(ptr));
218
+          ptr++;
219
+          arg_val--;
220
+        }
221
+      }
222
+      break;
223
+      
224
+    case U8G_COM_MSG_ADDRESS:                     /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
225
+      u8g_com_arduino_digital_write(u8g, U8G_PI_A0, arg_val);
226
+      break;
227
+  }
228
+  return 1;
229
+}
230
+
231
+#else /* ARDUINO */
232
+
233
+uint8_t u8g_com_arduino_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
234
+{
235
+  return 1;
236
+}
237
+
238
+#endif /* ARDUINO */
239
+

+ 385
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_t6963.c View File

@@ -0,0 +1,385 @@
1
+/*
2
+  
3
+  u8g_com_arduino_t6963.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+
34
+
35
+  PIN_D0 8
36
+  PIN_D1 9
37
+  PIN_D2 10
38
+  PIN_D3 11
39
+  PIN_D4 4
40
+  PIN_D5 5
41
+  PIN_D6 6
42
+  PIN_D7 7
43
+
44
+  PIN_CS 14
45
+  PIN_A0 15
46
+  PIN_RESET 16
47
+  PIN_WR 17
48
+  PIN_RD 18
49
+  
50
+  u8g_InitRW8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, cs, a0, wr, rd, reset)
51
+  u8g_InitRW8Bit(u8g, dev,  8,  9, 10, 11,  4,  5,  6,  7, 14, 15, 17, 18, 16)
52
+
53
+*/
54
+
55
+#include "u8g.h"
56
+
57
+#if  defined(ARDUINO)
58
+
59
+#if ARDUINO < 100 
60
+//#include <WProgram.h> 
61
+#include <wiring_private.h> 
62
+#include <pins_arduino.h> 
63
+#else 
64
+#include <Arduino.h> 
65
+#endif
66
+
67
+
68
+#if defined(__PIC32MX)
69
+/* CHIPKIT PIC32 */
70
+static volatile uint32_t *u8g_output_data_port[8];
71
+static volatile uint32_t *u8g_input_data_port[8];
72
+static volatile uint32_t *u8g_mode_port[8];
73
+static uint32_t u8g_data_mask[8];
74
+#else
75
+static volatile uint8_t *u8g_output_data_port[8];
76
+static volatile uint8_t *u8g_input_data_port[8];
77
+static volatile uint8_t *u8g_mode_port[8];
78
+static uint8_t u8g_data_mask[8];
79
+#endif
80
+
81
+
82
+
83
+static void u8g_com_arduino_t6963_init(u8g_t *u8g)
84
+{
85
+  u8g_output_data_port[0] =  portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D0]));
86
+  u8g_input_data_port[0] =  portInputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D0]));
87
+  u8g_mode_port[0] =  portModeRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D0]));
88
+  u8g_data_mask[0] =  digitalPinToBitMask(u8g->pin_list[U8G_PI_D0]);
89
+  
90
+  u8g_output_data_port[1] =  portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D1]));
91
+  u8g_input_data_port[1] =  portInputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D1]));
92
+  u8g_mode_port[1] =  portModeRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D1]));
93
+  u8g_data_mask[1] =  digitalPinToBitMask(u8g->pin_list[U8G_PI_D1]);
94
+  
95
+  u8g_output_data_port[2] =  portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D2]));
96
+  u8g_input_data_port[2] =  portInputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D2]));
97
+  u8g_mode_port[2] =  portModeRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D2]));
98
+  u8g_data_mask[2] =  digitalPinToBitMask(u8g->pin_list[U8G_PI_D2]);
99
+  
100
+  u8g_output_data_port[3] =  portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D3]));
101
+  u8g_input_data_port[3] =  portInputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D3]));
102
+  u8g_mode_port[3] =  portModeRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D3]));
103
+  u8g_data_mask[3] =  digitalPinToBitMask(u8g->pin_list[U8G_PI_D3]);
104
+  
105
+  u8g_output_data_port[4] =  portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D4]));
106
+  u8g_input_data_port[4] =  portInputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D4]));
107
+  u8g_mode_port[4] =  portModeRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D4]));
108
+  u8g_data_mask[4] =  digitalPinToBitMask(u8g->pin_list[U8G_PI_D4]);
109
+  
110
+  u8g_output_data_port[5] =  portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D5]));
111
+  u8g_input_data_port[5] =  portInputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D5]));
112
+  u8g_mode_port[5] =  portModeRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D5]));
113
+  u8g_data_mask[5] =  digitalPinToBitMask(u8g->pin_list[U8G_PI_D5]);
114
+  
115
+  u8g_output_data_port[6] =  portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D6]));
116
+  u8g_input_data_port[6] =  portInputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D6]));
117
+  u8g_mode_port[6] =  portModeRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D6]));
118
+  u8g_data_mask[6] =  digitalPinToBitMask(u8g->pin_list[U8G_PI_D6]);
119
+  
120
+  u8g_output_data_port[7] =  portOutputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D7]));
121
+  u8g_input_data_port[7] =  portInputRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D7]));
122
+  u8g_mode_port[7] =  portModeRegister(digitalPinToPort(u8g->pin_list[U8G_PI_D7]));
123
+  u8g_data_mask[7] =  digitalPinToBitMask(u8g->pin_list[U8G_PI_D7]);  
124
+}
125
+
126
+static void u8g_com_arduino_t6963_write_data_pin(uint8_t pin, uint8_t val)
127
+{
128
+  if ( val != 0 )
129
+    *u8g_output_data_port[pin] |= u8g_data_mask[pin];
130
+  else
131
+    *u8g_output_data_port[pin] &= ~u8g_data_mask[pin];
132
+}
133
+
134
+static void u8g_com_arduino_t6963_set_port_output(void)
135
+{
136
+  uint8_t i;
137
+  for( i = 0; i < 8; i++ )
138
+  {
139
+#if defined(__PIC32MX)
140
+/* CHIPKIT PIC32 */
141
+      *u8g_mode_port[i] |= u8g_data_mask[i]; 
142
+#elif defined(__AVR__)
143
+      *u8g_mode_port[i] |= u8g_data_mask[i]; 
144
+#else
145
+      /* TODO: use generic Arduino API */
146
+      *u8g_mode_port[i] |= u8g_data_mask[i]; 
147
+#endif
148
+
149
+  }
150
+}
151
+
152
+static void u8g_com_arduino_t6963_set_port_input(void)
153
+{
154
+  uint8_t i;
155
+  for( i = 0; i < 8; i++ )
156
+  {
157
+#if defined(__PIC32MX)
158
+/* CHIPKIT PIC32 */
159
+      *u8g_mode_port[i] &= ~u8g_data_mask[i]; 
160
+#elif defined(__AVR__)
161
+/* avr */
162
+      *u8g_mode_port[i] &= ~u8g_data_mask[i]; 
163
+      *u8g_output_data_port[i] &= ~u8g_data_mask[i]; 	// no pullup
164
+#else
165
+      /* TODO: use generic Arduino API */
166
+      *u8g_mode_port[i] &= ~u8g_data_mask[i]; 
167
+      *u8g_output_data_port[i] &= ~u8g_data_mask[i]; 	// no pullup
168
+#endif
169
+  }
170
+}
171
+
172
+
173
+static void u8g_com_arduino_t6963_write(u8g_t *u8g, uint8_t val)
174
+{
175
+  u8g_com_arduino_t6963_write_data_pin( 0, val&1 );
176
+  val >>= 1;
177
+  u8g_com_arduino_t6963_write_data_pin( 1, val&1 );
178
+  val >>= 1;
179
+  u8g_com_arduino_t6963_write_data_pin( 2, val&1 );
180
+  val >>= 1;
181
+  u8g_com_arduino_t6963_write_data_pin( 3, val&1 );
182
+  val >>= 1;
183
+
184
+  u8g_com_arduino_t6963_write_data_pin( 4, val&1 );
185
+  val >>= 1;
186
+  u8g_com_arduino_t6963_write_data_pin( 5, val&1 );
187
+  val >>= 1;
188
+  u8g_com_arduino_t6963_write_data_pin( 6, val&1 );
189
+  val >>= 1;
190
+  u8g_com_arduino_t6963_write_data_pin( 7, val&1 );
191
+  val >>= 1;
192
+  
193
+  u8g_com_arduino_digital_write(u8g, U8G_PI_WR, 0);
194
+  u8g_MicroDelay(); /* 80ns, reference: t6963 datasheet */
195
+  u8g_com_arduino_digital_write(u8g, U8G_PI_WR, 1);
196
+  u8g_MicroDelay(); /* 10ns, reference: t6963 datasheet */
197
+}
198
+
199
+static uint8_t u8g_com_arduino_t6963_read(u8g_t *u8g)
200
+{
201
+  uint8_t val = 0;
202
+  
203
+  u8g_com_arduino_digital_write(u8g, U8G_PI_RD, 0);
204
+  u8g_MicroDelay(); /* 150ns, reference: t6963 datasheet */
205
+  
206
+  /* only read bits 0, 1 and 3 */
207
+  if ( (*u8g_input_data_port[3] & u8g_data_mask[3]) != 0 )
208
+    val++;
209
+  val <<= 1;
210
+  val <<= 1;
211
+  if ( (*u8g_input_data_port[1] & u8g_data_mask[1]) != 0 )
212
+    val++;
213
+  val <<= 1;
214
+  if ( (*u8g_input_data_port[0] & u8g_data_mask[0]) != 0 )
215
+    val++;
216
+    
217
+  u8g_com_arduino_digital_write(u8g, U8G_PI_RD, 1);
218
+  u8g_MicroDelay(); /* 10ns, reference: t6963 datasheet */
219
+  
220
+  return val;
221
+}
222
+
223
+#define U8G_STATUS_TIMEOUT 50
224
+
225
+static uint8_t u8g_com_arduino_t6963_until_01_ok(u8g_t *u8g)
226
+{
227
+  long x;
228
+  
229
+  u8g_com_arduino_t6963_set_port_input();
230
+  x = millis();
231
+  x += U8G_STATUS_TIMEOUT;
232
+
233
+  for(;;)
234
+  {    
235
+    if ( (u8g_com_arduino_t6963_read(u8g) & 3) == 3 )
236
+      break;
237
+    if ( x < millis() )
238
+      return 0;
239
+  }
240
+  u8g_com_arduino_t6963_set_port_output();
241
+  return 1;
242
+}
243
+
244
+static uint8_t u8g_com_arduino_t6963_until_3_ok(u8g_t *u8g)
245
+{
246
+  long x;
247
+  
248
+  u8g_com_arduino_t6963_set_port_input();
249
+  x = millis();
250
+  x += U8G_STATUS_TIMEOUT;
251
+
252
+  for(;;)
253
+  {    
254
+    if ( (u8g_com_arduino_t6963_read(u8g) & 8) == 8 )
255
+      break;
256
+    if ( x < millis() )
257
+      return 0;
258
+  }
259
+  u8g_com_arduino_t6963_set_port_output();
260
+  return 1;
261
+}
262
+
263
+static uint8_t u8g_com_arduino_t6963_write_cmd(u8g_t *u8g, uint8_t val)
264
+{
265
+  u8g_com_arduino_digital_write(u8g, U8G_PI_A0, 1);
266
+  if ( u8g_com_arduino_t6963_until_01_ok(u8g) == 0 )
267
+    return 0;
268
+  u8g_com_arduino_digital_write(u8g, U8G_PI_A0, 1);
269
+  u8g_com_arduino_t6963_write(u8g, val);
270
+  return 1;  
271
+}
272
+
273
+static uint8_t u8g_com_arduino_t6963_write_data(u8g_t *u8g, uint8_t val)
274
+{
275
+  u8g_com_arduino_digital_write(u8g, U8G_PI_A0, 1);
276
+  if ( u8g_com_arduino_t6963_until_01_ok(u8g) == 0 )
277
+    return 0;
278
+  u8g_com_arduino_digital_write(u8g, U8G_PI_A0, 0);
279
+  u8g_com_arduino_t6963_write(u8g, val);
280
+  return 1;  
281
+}
282
+
283
+static uint8_t u8g_com_arduino_t6963_write_auto_data(u8g_t *u8g, uint8_t val)
284
+{
285
+  u8g_com_arduino_digital_write(u8g, U8G_PI_A0, 1);
286
+  if ( u8g_com_arduino_t6963_until_3_ok(u8g) == 0 )
287
+    return 0;
288
+  u8g_com_arduino_digital_write(u8g, U8G_PI_A0, 0);
289
+  u8g_com_arduino_t6963_write(u8g, val);
290
+  return 1;  
291
+}
292
+
293
+
294
+uint8_t u8g_com_arduino_t6963_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
295
+{
296
+  switch(msg)
297
+  {
298
+    case U8G_COM_MSG_INIT:
299
+      u8g->pin_list[U8G_PI_A0_STATE] = 0;
300
+      u8g_com_arduino_t6963_init(u8g);
301
+      /* setup the RW (equal to WR) pin as output and force it to high */
302
+      if ( u8g->pin_list[U8G_PI_WR] != U8G_PIN_NONE )
303
+      {
304
+        pinMode(u8g->pin_list[U8G_PI_WR], OUTPUT);
305
+        u8g_com_arduino_digital_write(u8g, U8G_PI_WR, HIGH);
306
+      }
307
+      /* set all pins (except WR pin) */
308
+      u8g_com_arduino_assign_pin_output_high(u8g);
309
+      break;
310
+    case U8G_COM_MSG_STOP:
311
+      break;
312
+
313
+    case U8G_COM_MSG_CHIP_SELECT:
314
+      if ( arg_val == 0 )
315
+      {
316
+        /* disable, active low chip select */
317
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS, HIGH);
318
+      }
319
+      else
320
+      {
321
+        /* enable */
322
+        u8g_com_arduino_digital_write(u8g, U8G_PI_CS, LOW);
323
+      }
324
+      break;
325
+    case U8G_COM_MSG_WRITE_BYTE:
326
+      if ( u8g->pin_list[U8G_PI_A0_STATE] == 0 )
327
+      {
328
+	u8g_com_arduino_t6963_write_data(u8g, arg_val);
329
+      }
330
+      else
331
+      {
332
+	u8g_com_arduino_t6963_write_cmd(u8g, arg_val);
333
+      }
334
+      break;
335
+    case U8G_COM_MSG_WRITE_SEQ:
336
+      {
337
+        register uint8_t *ptr = arg_ptr;
338
+	u8g_com_arduino_t6963_write_cmd(u8g, 0x0b0);	/* auto write */
339
+        while( arg_val > 0 )
340
+        {
341
+          if ( u8g_com_arduino_t6963_write_auto_data(u8g, *ptr++) == 0 )
342
+	    break;
343
+          arg_val--;
344
+        }
345
+	u8g_com_arduino_t6963_write_cmd(u8g, 0x0b2);	/* auto reset */
346
+      }
347
+      break;
348
+    case U8G_COM_MSG_WRITE_SEQ_P:
349
+      {
350
+        register uint8_t *ptr = arg_ptr;
351
+	u8g_com_arduino_t6963_write_cmd(u8g, 0x0b0);	/* auto write */
352
+        while( arg_val > 0 )
353
+        {
354
+          if ( u8g_com_arduino_t6963_write_auto_data(u8g, u8g_pgm_read(ptr)) == 0 )
355
+	    break;
356
+          ptr++;
357
+          arg_val--;
358
+        }
359
+	u8g_com_arduino_t6963_write_cmd(u8g, 0x0b2);	/* auto reset */
360
+      }
361
+      break;
362
+    case U8G_COM_MSG_ADDRESS:                     /* define cmd (arg_val = 1) or data mode (arg_val = 0) */
363
+      u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
364
+      //u8g_com_arduino_digital_write(u8g, U8G_PI_DI, arg_val);
365
+      break;
366
+    case U8G_COM_MSG_RESET:
367
+      if ( u8g->pin_list[U8G_PI_RESET] != U8G_PIN_NONE )
368
+        u8g_com_arduino_digital_write(u8g, U8G_PI_RESET, arg_val);
369
+      break;
370
+      
371
+  }
372
+  return 1;
373
+}
374
+
375
+#else
376
+
377
+
378
+uint8_t u8g_com_arduino_t6963_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
379
+{
380
+  return 1;
381
+}
382
+
383
+
384
+#endif /* ARDUINO */
385
+

+ 174
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_atmega_hw_spi.c View File

@@ -0,0 +1,174 @@
1
+/*
2
+  
3
+  u8g_com_atmega_hw_spi.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2012, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+  
35
+  Assumes, that 
36
+    MOSI is at PORTB, Pin 3
37
+  and
38
+    SCK is at PORTB, Pin 5
39
+
40
+*/
41
+
42
+#include "u8g.h"
43
+
44
+
45
+#if defined(__AVR__)
46
+#define U8G_ATMEGA_HW_SPI
47
+
48
+/* remove the definition for attiny */
49
+#if __AVR_ARCH__ == 2
50
+#undef U8G_ATMEGA_HW_SPI
51
+#endif
52
+#if __AVR_ARCH__ == 25
53
+#undef U8G_ATMEGA_HW_SPI
54
+#endif
55
+#endif
56
+
57
+
58
+#if defined(U8G_ATMEGA_HW_SPI)
59
+
60
+#include <avr/interrupt.h>
61
+#include <avr/io.h>
62
+
63
+
64
+static uint8_t u8g_atmega_spi_out(uint8_t data)
65
+{
66
+  /* unsigned char x = 100; */
67
+  /* send data */
68
+  SPDR = data;
69
+  /* wait for transmission */
70
+  while (!(SPSR & (1<<SPIF))) 
71
+    ;
72
+  /* clear the SPIF flag by reading SPDR */
73
+  return  SPDR;
74
+}
75
+
76
+
77
+uint8_t u8g_com_atmega_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
78
+{
79
+  switch(msg)
80
+  {
81
+    case U8G_COM_MSG_STOP:
82
+      break;
83
+    
84
+    case U8G_COM_MSG_INIT:
85
+
86
+      u8g_SetPIOutput(u8g, U8G_PI_CS);
87
+      u8g_SetPIOutput(u8g, U8G_PI_A0);
88
+      
89
+      DDRB |= _BV(3);          /* D0, MOSI */
90
+      DDRB |= _BV(5);          /* SCK */
91
+      DDRB |= _BV(2);		/* slave select */
92
+    
93
+      PORTB &= ~_BV(3);        /* D0, MOSI = 0 */
94
+      PORTB &= ~_BV(5);        /* SCK = 0 */
95
+      u8g_SetPILevel(u8g, U8G_PI_CS, 1);
96
+
97
+      /*
98
+        SPR1 SPR0
99
+            0	0		fclk/4    x
100
+            0	1		fclk/16
101
+            1	0		fclk/64      
102
+            1	1		fclk/128
103
+      */
104
+      SPCR = 0;
105
+      SPCR =  (1<<SPE) | (1<<MSTR)|(0<<SPR1)|(0<<SPR0)|(0<<CPOL)|(0<<CPHA);
106
+#ifdef U8G_HW_SPI_2X
107
+      SPSR = (1 << SPI2X);  /* double speed, issue 89 */
108
+#endif
109
+
110
+      break;
111
+    
112
+    case U8G_COM_MSG_ADDRESS:                     /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
113
+      u8g_SetPILevel(u8g, U8G_PI_A0, arg_val);
114
+      break;
115
+
116
+    case U8G_COM_MSG_CHIP_SELECT:
117
+      
118
+      if ( arg_val == 0 )
119
+      {
120
+        /* disable */
121
+        u8g_SetPILevel(u8g, U8G_PI_CS, 1);
122
+      }
123
+      else
124
+      {
125
+        PORTB &= ~_BV(5);        /* SCK = 0 */
126
+        /* enable */
127
+        u8g_SetPILevel(u8g, U8G_PI_CS, 0); /* CS = 0 (low active) */
128
+      }
129
+      
130
+      break;
131
+      
132
+    case U8G_COM_MSG_RESET:
133
+      u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val);
134
+      break;
135
+    
136
+    case U8G_COM_MSG_WRITE_BYTE:
137
+      u8g_atmega_spi_out(arg_val);
138
+      break;
139
+    
140
+    case U8G_COM_MSG_WRITE_SEQ:
141
+      {
142
+        register uint8_t *ptr = arg_ptr;
143
+        while( arg_val > 0 )
144
+        {
145
+          u8g_atmega_spi_out(*ptr++);
146
+          arg_val--;
147
+        }
148
+      }
149
+      break;
150
+    case U8G_COM_MSG_WRITE_SEQ_P:
151
+      {
152
+        register uint8_t *ptr = arg_ptr;
153
+        while( arg_val > 0 )
154
+        {
155
+          u8g_atmega_spi_out(u8g_pgm_read(ptr));
156
+          ptr++;
157
+          arg_val--;
158
+        }
159
+      }
160
+      break;
161
+  }
162
+  return 1;
163
+}
164
+
165
+#else
166
+
167
+uint8_t u8g_com_atmega_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
168
+{
169
+  return 1;
170
+}
171
+
172
+#endif
173
+
174
+

+ 183
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_atmega_parallel.c View File

@@ -0,0 +1,183 @@
1
+/*
2
+  
3
+  u8g_atmega_parallel.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2012, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+
35
+  PIN_D0 8
36
+  PIN_D1 9
37
+  PIN_D2 10
38
+  PIN_D3 11
39
+  PIN_D4 4
40
+  PIN_D5 5
41
+  PIN_D6 6
42
+  PIN_D7 7
43
+
44
+  PIN_CS1 14
45
+  PIN_CS2 15
46
+  PIN_RW 16
47
+  PIN_DI 17
48
+  PIN_EN 18
49
+  
50
+  u8g_Init8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset)
51
+  u8g_Init8Bit(u8g, dev,  8,    9, 10, 11,   4,   5,   6,   7, 18, 14, 15, 17, 16, U8G_PIN_NONE)
52
+
53
+*/
54
+
55
+#include "u8g.h"
56
+
57
+#if defined(__AVR__)
58
+
59
+static void u8g_com_atmega_parallel_write(u8g_t *u8g, uint8_t val) U8G_NOINLINE;
60
+static void u8g_com_atmega_parallel_write(u8g_t *u8g, uint8_t val)
61
+{
62
+
63
+  u8g_SetPILevel(u8g, U8G_PI_D0, val&1);
64
+  val >>= 1;
65
+  u8g_SetPILevel(u8g, U8G_PI_D1, val&1);
66
+  val >>= 1;
67
+  u8g_SetPILevel(u8g, U8G_PI_D2, val&1);
68
+  val >>= 1;
69
+  u8g_SetPILevel(u8g, U8G_PI_D3, val&1);
70
+  val >>= 1;
71
+  u8g_SetPILevel(u8g, U8G_PI_D4, val&1);
72
+  val >>= 1;
73
+  u8g_SetPILevel(u8g, U8G_PI_D5, val&1);
74
+  val >>= 1;
75
+  u8g_SetPILevel(u8g, U8G_PI_D6, val&1);
76
+  val >>= 1;
77
+  u8g_SetPILevel(u8g, U8G_PI_D7, val&1);
78
+  
79
+  /* EN cycle time must be 1 micro second  */
80
+  u8g_SetPILevel(u8g, U8G_PI_EN, 1);
81
+  u8g_MicroDelay(); /* delay by 1000ns, reference: ST7920: 140ns, SBN1661: 100ns */
82
+  u8g_SetPILevel(u8g, U8G_PI_EN, 0);
83
+  u8g_10MicroDelay(); /* ST7920 commands: 72us */
84
+  u8g_10MicroDelay(); /* ST7920 commands: 72us */
85
+}
86
+
87
+
88
+uint8_t u8g_com_atmega_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
89
+{
90
+  switch(msg)
91
+  {
92
+    case U8G_COM_MSG_INIT:
93
+      /* setup the RW pin as output and force it to low */
94
+      u8g_SetPIOutput(u8g, U8G_PI_RW);
95
+      u8g_SetPILevel(u8g, U8G_PI_RW, 0);
96
+
97
+      u8g_SetPIOutput(u8g, U8G_PI_D0);
98
+      u8g_SetPIOutput(u8g, U8G_PI_D1);
99
+      u8g_SetPIOutput(u8g, U8G_PI_D2);
100
+      u8g_SetPIOutput(u8g, U8G_PI_D3);
101
+      u8g_SetPIOutput(u8g, U8G_PI_D4);
102
+      u8g_SetPIOutput(u8g, U8G_PI_D5);
103
+      u8g_SetPIOutput(u8g, U8G_PI_D6);
104
+      u8g_SetPIOutput(u8g, U8G_PI_D7);
105
+      u8g_SetPIOutput(u8g, U8G_PI_EN);
106
+      u8g_SetPIOutput(u8g, U8G_PI_CS1);
107
+      u8g_SetPIOutput(u8g, U8G_PI_CS2);
108
+      u8g_SetPIOutput(u8g, U8G_PI_DI);
109
+      u8g_SetPILevel(u8g, U8G_PI_CS1, 1);
110
+      u8g_SetPILevel(u8g, U8G_PI_CS2, 1);
111
+
112
+      break;
113
+    case U8G_COM_MSG_STOP:
114
+      break;
115
+    case U8G_COM_MSG_CHIP_SELECT:
116
+      if ( arg_val == 0 )
117
+      {
118
+        /* disable */
119
+        u8g_SetPILevel(u8g, U8G_PI_CS1, 1);
120
+        u8g_SetPILevel(u8g, U8G_PI_CS2, 1);
121
+      }
122
+      else if ( arg_val == 1 )
123
+      {
124
+        /* enable */
125
+        u8g_SetPILevel(u8g, U8G_PI_CS1, 0);
126
+        u8g_SetPILevel(u8g, U8G_PI_CS2, 1);
127
+      }
128
+      else if ( arg_val == 2 )
129
+      {
130
+        /* enable */
131
+        u8g_SetPILevel(u8g, U8G_PI_CS1, 1);
132
+        u8g_SetPILevel(u8g, U8G_PI_CS2, 0);
133
+      }
134
+      else
135
+      {
136
+        /* enable */
137
+        u8g_SetPILevel(u8g, U8G_PI_CS1, 0);
138
+        u8g_SetPILevel(u8g, U8G_PI_CS2, 0);
139
+      }
140
+      break;
141
+    case U8G_COM_MSG_WRITE_BYTE:
142
+      u8g_com_atmega_parallel_write(u8g, arg_val);
143
+      break;
144
+    case U8G_COM_MSG_WRITE_SEQ:
145
+      {
146
+        register uint8_t *ptr = arg_ptr;
147
+        while( arg_val > 0 )
148
+        {
149
+          u8g_com_atmega_parallel_write(u8g, *ptr++);
150
+          arg_val--;
151
+        }
152
+      }
153
+      break;
154
+    case U8G_COM_MSG_WRITE_SEQ_P:
155
+      {
156
+        register uint8_t *ptr = arg_ptr;
157
+        while( arg_val > 0 )
158
+        {
159
+          u8g_com_atmega_parallel_write(u8g, u8g_pgm_read(ptr));
160
+          ptr++;
161
+          arg_val--;
162
+        }
163
+      }
164
+      break;
165
+    case U8G_COM_MSG_ADDRESS:                     /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
166
+      u8g_SetPILevel(u8g, U8G_PI_DI, arg_val);
167
+      break;
168
+    case U8G_COM_MSG_RESET:
169
+      u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val);
170
+      break;
171
+  }
172
+  return 1;
173
+}
174
+
175
+#else
176
+
177
+uint8_t u8g_com_atmega_parallel_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
178
+{
179
+  return 1;
180
+}
181
+
182
+#endif /* ARDUINO */
183
+

+ 205
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_atmega_st7920_hw_spi.c View File

@@ -0,0 +1,205 @@
1
+/*
2
+  
3
+  u8g_com_atmega_st7920_hw_spi.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+
34
+  A special SPI interface for ST7920 controller with HW SPI Support
35
+
36
+  Assumes, that 
37
+    MOSI is at PORTB, Pin 3
38
+  and
39
+    SCK is at PORTB, Pin 5
40
+
41
+
42
+*/
43
+
44
+#include "u8g.h"
45
+
46
+#if defined(__AVR__)
47
+#define U8G_ATMEGA_HW_SPI
48
+
49
+/* remove the definition for attiny */
50
+#if __AVR_ARCH__ == 2
51
+#undef U8G_ATMEGA_HW_SPI
52
+#endif
53
+#if __AVR_ARCH__ == 25
54
+#undef U8G_ATMEGA_HW_SPI
55
+#endif
56
+
57
+#endif
58
+
59
+#if defined(U8G_ATMEGA_HW_SPI)
60
+
61
+#include <avr/interrupt.h>
62
+#include <avr/io.h>
63
+
64
+static uint8_t u8g_atmega_st7920_hw_spi_shift_out(u8g_t *u8g, uint8_t val) U8G_NOINLINE;
65
+static uint8_t u8g_atmega_st7920_hw_spi_shift_out(u8g_t *u8g, uint8_t val)
66
+{
67
+  /* send data */
68
+  SPDR = val;
69
+  /* wait for transmission */
70
+  while (!(SPSR & (1<<SPIF))) 
71
+    ;
72
+  /* clear the SPIF flag by reading SPDR */
73
+  return  SPDR;
74
+}
75
+
76
+
77
+static void u8g_com_atmega_st7920_write_byte_hw_spi(u8g_t *u8g, uint8_t rs, uint8_t val) U8G_NOINLINE;
78
+static void u8g_com_atmega_st7920_write_byte_hw_spi(u8g_t *u8g, uint8_t rs, uint8_t val)
79
+{
80
+  uint8_t i;
81
+
82
+  if ( rs == 0 )
83
+  {
84
+    /* command */
85
+    u8g_atmega_st7920_hw_spi_shift_out(u8g, 0x0f8);
86
+  }
87
+  else if ( rs == 1 )
88
+  {
89
+    /* data */
90
+    u8g_atmega_st7920_hw_spi_shift_out(u8g, 0x0fa);
91
+  }
92
+  
93
+  u8g_atmega_st7920_hw_spi_shift_out(u8g, val & 0x0f0);
94
+  u8g_atmega_st7920_hw_spi_shift_out(u8g, val << 4);
95
+
96
+  for( i = 0; i < 4; i++ )
97
+    u8g_10MicroDelay();
98
+}
99
+
100
+
101
+uint8_t u8g_com_atmega_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
102
+{
103
+  switch(msg)
104
+  {
105
+    case U8G_COM_MSG_INIT:
106
+      u8g_SetPIOutput(u8g, U8G_PI_CS);
107
+      //u8g_SetPIOutput(u8g, U8G_PI_A0);
108
+      
109
+      DDRB |= _BV(3);          /* D0, MOSI */
110
+      DDRB |= _BV(5);          /* SCK */
111
+      DDRB |= _BV(2);		/* slave select */
112
+    
113
+      PORTB &= ~_BV(3);        /* D0, MOSI = 0 */
114
+      PORTB &= ~_BV(5);        /* SCK = 0 */
115
+      u8g_SetPILevel(u8g, U8G_PI_CS, 1);
116
+
117
+      /*
118
+        SPR1 SPR0
119
+            0	0		fclk/4
120
+            0	1		fclk/16 
121
+            1	0		fclk/64  
122
+            1	1		fclk/128
123
+      */
124
+      SPCR = 0;
125
+      
126
+      /* maybe set CPOL and CPHA to 1 */
127
+      /* 20 Dez 2012: did set CPOL and CPHA to 1 in Arduino variant! */
128
+      SPCR =  (1<<SPE) | (1<<MSTR)|(0<<SPR1)|(0<<SPR0)|(0<<CPOL)|(0<<CPHA);
129
+#ifdef U8G_HW_SPI_2X
130
+      SPSR = (1 << SPI2X);  /* double speed, issue 89 */
131
+#endif
132
+      u8g->pin_list[U8G_PI_A0_STATE] = 0;       /* inital RS state: command mode */
133
+      break;
134
+    
135
+    case U8G_COM_MSG_STOP:
136
+      break;
137
+
138
+    case U8G_COM_MSG_RESET:
139
+      u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val);
140
+      break;
141
+    
142
+    case U8G_COM_MSG_ADDRESS:                     /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
143
+      u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
144
+      break;
145
+
146
+    case U8G_COM_MSG_CHIP_SELECT:      
147
+      if ( arg_val == 0 )
148
+      {
149
+        /* disable, note: the st7920 has an active high chip select */
150
+        u8g_SetPILevel(u8g, U8G_PI_CS, 0);
151
+      }
152
+      else
153
+      {
154
+        /* u8g_SetPILevel(u8g, U8G_PI_SCK, 0 ); */
155
+        /* enable */
156
+        u8g_SetPILevel(u8g, U8G_PI_CS, 1); /* CS = 1 (high active) */
157
+      }
158
+      break;
159
+      
160
+
161
+    case U8G_COM_MSG_WRITE_BYTE:
162
+      u8g_com_atmega_st7920_write_byte_hw_spi(u8g, u8g->pin_list[U8G_PI_A0_STATE], arg_val);
163
+      //u8g->pin_list[U8G_PI_A0_STATE] = 2; 
164
+      break;
165
+    
166
+    case U8G_COM_MSG_WRITE_SEQ:
167
+      {
168
+        register uint8_t *ptr = arg_ptr;
169
+        while( arg_val > 0 )
170
+        {
171
+          u8g_com_atmega_st7920_write_byte_hw_spi(u8g, u8g->pin_list[U8G_PI_A0_STATE], *ptr++);
172
+	  //u8g->pin_list[U8G_PI_A0_STATE] = 2; 
173
+          arg_val--;
174
+        }
175
+      }
176
+      break;
177
+
178
+      case U8G_COM_MSG_WRITE_SEQ_P:
179
+      {
180
+        register uint8_t *ptr = arg_ptr;
181
+        while( arg_val > 0 )
182
+        {
183
+          u8g_com_atmega_st7920_write_byte_hw_spi(u8g, u8g->pin_list[U8G_PI_A0_STATE], u8g_pgm_read(ptr));
184
+	  //u8g->pin_list[U8G_PI_A0_STATE] = 2; 
185
+          ptr++;
186
+          arg_val--;
187
+        }
188
+      }
189
+      break;
190
+  }
191
+  return 1;
192
+}
193
+
194
+#else
195
+
196
+
197
+uint8_t u8g_com_atmega_st7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
198
+{
199
+  return 1;
200
+}
201
+
202
+
203
+#endif
204
+
205
+ 

+ 170
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_atmega_st7920_spi.c View File

@@ -0,0 +1,170 @@
1
+/*
2
+  
3
+  u8g_com_atmega_st7920_spi.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+
34
+  A special SPI interface for ST7920 controller
35
+
36
+*/
37
+
38
+#include "u8g.h"
39
+
40
+#if defined(__AVR__)
41
+
42
+static void u8g_atmega_st7920_sw_spi_shift_out(u8g_t *u8g, uint8_t val) U8G_NOINLINE;
43
+static void u8g_atmega_st7920_sw_spi_shift_out(u8g_t *u8g, uint8_t val)
44
+{
45
+  uint8_t i = 8;
46
+  do
47
+  {
48
+    u8g_SetPILevel(u8g, U8G_PI_MOSI, val & 128 );
49
+    val <<= 1;
50
+    u8g_SetPILevel(u8g, U8G_PI_SCK, 1 );
51
+    u8g_MicroDelay();		/* 15 Aug 2012: added for high speed uC */
52
+    u8g_SetPILevel(u8g, U8G_PI_SCK, 0 );
53
+    u8g_MicroDelay();		/* 15 Aug 2012: added for high speed uC */
54
+    i--;
55
+  } while( i != 0 );
56
+}
57
+
58
+static void u8g_com_atmega_st7920_write_byte(u8g_t *u8g, uint8_t rs, uint8_t val) U8G_NOINLINE;
59
+static void u8g_com_atmega_st7920_write_byte(u8g_t *u8g, uint8_t rs, uint8_t val)
60
+{
61
+  uint8_t i;
62
+  
63
+  if ( rs == 0 )
64
+  {
65
+    /* command */
66
+    u8g_atmega_st7920_sw_spi_shift_out(u8g, 0x0f8);
67
+  }
68
+  else if ( rs == 1 )
69
+  {
70
+    /* data */
71
+    u8g_atmega_st7920_sw_spi_shift_out(u8g, 0x0fa);
72
+  }
73
+  
74
+  u8g_atmega_st7920_sw_spi_shift_out(u8g, val & 0x0f0);
75
+  u8g_atmega_st7920_sw_spi_shift_out(u8g, val << 4);
76
+
77
+  for( i = 0; i < 4; i++ )
78
+    u8g_10MicroDelay();
79
+}
80
+
81
+
82
+uint8_t u8g_com_atmega_st7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
83
+{
84
+  switch(msg)
85
+  {
86
+    case U8G_COM_MSG_INIT:
87
+      u8g_SetPIOutput(u8g, U8G_PI_SCK);
88
+      u8g_SetPIOutput(u8g, U8G_PI_MOSI);
89
+      /* u8g_SetPIOutput(u8g, U8G_PI_A0); */
90
+      u8g_SetPIOutput(u8g, U8G_PI_CS);
91
+      u8g_SetPIOutput(u8g, U8G_PI_RESET);
92
+      
93
+      u8g_SetPILevel(u8g, U8G_PI_SCK, 0 );
94
+      u8g_SetPILevel(u8g, U8G_PI_MOSI, 0 );
95
+      u8g_SetPILevel(u8g, U8G_PI_CS, 0 );
96
+      /* u8g_SetPILevel(u8g, U8G_PI_A0, 0); */
97
+    
98
+      u8g->pin_list[U8G_PI_A0_STATE] = 0;       /* inital RS state: command mode */
99
+      break;
100
+    
101
+    case U8G_COM_MSG_STOP:
102
+      break;
103
+
104
+    case U8G_COM_MSG_RESET:
105
+      u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val);
106
+      break;
107
+    
108
+    case U8G_COM_MSG_ADDRESS:                     /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
109
+      u8g->pin_list[U8G_PI_A0_STATE] = arg_val;
110
+      break;
111
+
112
+    case U8G_COM_MSG_CHIP_SELECT:      
113
+      if ( arg_val == 0 )
114
+      {
115
+        /* disable, note: the st7920 has an active high chip select */
116
+        u8g_SetPILevel(u8g, U8G_PI_CS, 0);
117
+      }
118
+      else
119
+      {
120
+        /* u8g_SetPILevel(u8g, U8G_PI_SCK, 0 ); */
121
+        /* enable */
122
+        u8g_SetPILevel(u8g, U8G_PI_CS, 1); /* CS = 1 (high active) */
123
+      }
124
+      break;
125
+      
126
+
127
+    case U8G_COM_MSG_WRITE_BYTE:
128
+      u8g_com_atmega_st7920_write_byte(u8g, u8g->pin_list[U8G_PI_A0_STATE], arg_val);
129
+      u8g->pin_list[U8G_PI_A0_STATE] = 2; 
130
+      break;
131
+    
132
+    case U8G_COM_MSG_WRITE_SEQ:
133
+      {
134
+        register uint8_t *ptr = arg_ptr;
135
+        while( arg_val > 0 )
136
+        {
137
+          u8g_com_atmega_st7920_write_byte(u8g, u8g->pin_list[U8G_PI_A0_STATE], *ptr++);
138
+	  u8g->pin_list[U8G_PI_A0_STATE] = 2; 
139
+          arg_val--;
140
+        }
141
+      }
142
+      break;
143
+
144
+      case U8G_COM_MSG_WRITE_SEQ_P:
145
+      {
146
+        register uint8_t *ptr = arg_ptr;
147
+        while( arg_val > 0 )
148
+        {
149
+          u8g_com_atmega_st7920_write_byte(u8g, u8g->pin_list[U8G_PI_A0_STATE], u8g_pgm_read(ptr));
150
+	  u8g->pin_list[U8G_PI_A0_STATE] = 2; 
151
+          ptr++;
152
+          arg_val--;
153
+        }
154
+      }
155
+      break;
156
+  }
157
+  return 1;
158
+}
159
+
160
+#else
161
+
162
+
163
+uint8_t u8g_com_atmega_st7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
164
+{
165
+  return 1;
166
+}
167
+
168
+
169
+#endif
170
+

+ 141
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_atmega_sw_spi.c View File

@@ -0,0 +1,141 @@
1
+/*
2
+  
3
+  u8g_com_atmega_sw_spi.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2012, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+
35
+*/
36
+
37
+#include "u8g.h"
38
+
39
+#if defined(__AVR__)
40
+
41
+static void u8g_atmega_sw_spi_shift_out(u8g_t *u8g, uint8_t val) U8G_NOINLINE;
42
+static void u8g_atmega_sw_spi_shift_out(u8g_t *u8g, uint8_t val)
43
+{
44
+  uint8_t i = 8;
45
+  do
46
+  {
47
+    u8g_SetPILevel(u8g, U8G_PI_MOSI, val & 128 );
48
+    val <<= 1;
49
+    u8g_SetPILevel(u8g, U8G_PI_SCK, 1 );
50
+    u8g_MicroDelay();		/* 15 Aug 2012: added for high speed uC */
51
+    u8g_SetPILevel(u8g, U8G_PI_SCK, 0 );
52
+    u8g_MicroDelay();		/* 15 Aug 2012: added for high speed uC */
53
+    i--;
54
+  } while( i != 0 );
55
+}
56
+
57
+uint8_t u8g_com_atmega_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
58
+{
59
+  switch(msg)
60
+  {
61
+    case U8G_COM_MSG_INIT:
62
+      u8g_SetPIOutput(u8g, U8G_PI_SCK);
63
+      u8g_SetPIOutput(u8g, U8G_PI_MOSI);
64
+      u8g_SetPIOutput(u8g, U8G_PI_A0);
65
+      u8g_SetPIOutput(u8g, U8G_PI_CS);
66
+      u8g_SetPIOutput(u8g, U8G_PI_RESET);
67
+      
68
+      u8g_SetPILevel(u8g, U8G_PI_SCK, 0 );
69
+      u8g_SetPILevel(u8g, U8G_PI_MOSI, 0 );
70
+      u8g_SetPILevel(u8g, U8G_PI_CS, 1 );
71
+      u8g_SetPILevel(u8g, U8G_PI_A0, 0);
72
+      break;
73
+    
74
+    case U8G_COM_MSG_STOP:
75
+      break;
76
+
77
+    case U8G_COM_MSG_ADDRESS:                     /* define cmd (arg_val = 0) or data mode (arg_val = 1) */
78
+      u8g_SetPILevel(u8g, U8G_PI_A0, arg_val);
79
+      break;
80
+
81
+    case U8G_COM_MSG_CHIP_SELECT:
82
+      
83
+      if ( arg_val == 0 )
84
+      {
85
+        /* disable */
86
+        u8g_SetPILevel(u8g, U8G_PI_CS, 1);
87
+      }
88
+      else
89
+      {
90
+        u8g_SetPILevel(u8g, U8G_PI_SCK, 0 );
91
+        /* enable */
92
+        u8g_SetPILevel(u8g, U8G_PI_CS, 0); /* CS = 0 (low active) */
93
+      }
94
+      break;
95
+      
96
+    case U8G_COM_MSG_RESET:
97
+      u8g_SetPILevel(u8g, U8G_PI_RESET, arg_val);
98
+      break;
99
+    
100
+
101
+    case U8G_COM_MSG_WRITE_BYTE:
102
+      u8g_atmega_sw_spi_shift_out(u8g, arg_val);
103
+      break;
104
+    
105
+    case U8G_COM_MSG_WRITE_SEQ:
106
+      {
107
+        register uint8_t *ptr = arg_ptr;
108
+        while( arg_val > 0 )
109
+        {
110
+          u8g_atmega_sw_spi_shift_out(u8g, *ptr++);
111
+          arg_val--;
112
+        }
113
+      }
114
+      break;
115
+
116
+      case U8G_COM_MSG_WRITE_SEQ_P:
117
+      {
118
+        register uint8_t *ptr = arg_ptr;
119
+        while( arg_val > 0 )
120
+        {
121
+          u8g_atmega_sw_spi_shift_out(u8g, u8g_pgm_read(ptr));
122
+          ptr++;
123
+          arg_val--;
124
+        }
125
+      }
126
+      break;
127
+  }
128
+  return 1;
129
+}
130
+
131
+#else
132
+
133
+
134
+uint8_t u8g_com_atmega_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
135
+{
136
+  return 1;
137
+}
138
+
139
+
140
+#endif
141
+

+ 249
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_i2c.c View File

@@ -0,0 +1,249 @@
1
+/*
2
+  
3
+  u8g_com_i2c.c
4
+
5
+  generic i2c interface
6
+
7
+  Universal 8bit Graphics Library
8
+  
9
+  Copyright (c) 2011, olikraus@gmail.com
10
+  All rights reserved.
11
+
12
+  Redistribution and use in source and binary forms, with or without modification, 
13
+  are permitted provided that the following conditions are met:
14
+
15
+  * Redistributions of source code must retain the above copyright notice, this list 
16
+    of conditions and the following disclaimer.
17
+    
18
+  * Redistributions in binary form must reproduce the above copyright notice, this 
19
+    list of conditions and the following disclaimer in the documentation and/or other 
20
+    materials provided with the distribution.
21
+
22
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
23
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
24
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
25
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
26
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
27
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
28
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
29
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
30
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
31
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
32
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
33
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
34
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
35
+  
36
+*/
37
+
38
+#include "u8g.h"
39
+
40
+static uint8_t u8g_i2c_err_code;
41
+
42
+/*
43
+  position values
44
+    1: start condition
45
+    2: sla transfer
46
+*/
47
+static uint8_t u8g_i2c_err_pos;
48
+
49
+
50
+void u8g_i2c_clear_error(void)
51
+{
52
+  u8g_i2c_err_code = U8G_I2C_ERR_NONE;
53
+  u8g_i2c_err_pos = 0;
54
+}
55
+
56
+uint8_t  u8g_i2c_get_error(void)
57
+{
58
+  return u8g_i2c_err_code;
59
+}
60
+
61
+uint8_t u8g_i2c_get_err_pos(void)
62
+{
63
+  return u8g_i2c_err_pos;
64
+}
65
+
66
+static void u8g_i2c_set_error(uint8_t code, uint8_t pos)
67
+{
68
+  if ( u8g_i2c_err_code > 0 )
69
+    return;
70
+  u8g_i2c_err_code |= code;
71
+  u8g_i2c_err_pos = pos;
72
+}
73
+
74
+
75
+
76
+#if defined(__AVR__)
77
+#define U8G_ATMEGA_HW_TWI
78
+
79
+/* remove the definition for attiny */
80
+#if __AVR_ARCH__ == 2
81
+#undef U8G_ATMEGA_HW_TWI
82
+#endif
83
+#if __AVR_ARCH__ == 25
84
+#undef U8G_ATMEGA_HW_TWI
85
+#endif
86
+#endif
87
+
88
+#if defined(U8G_ATMEGA_HW_TWI)
89
+
90
+#include <avr/io.h>
91
+#include <util/twi.h>
92
+
93
+
94
+
95
+void u8g_i2c_init(uint8_t options)
96
+{
97
+  /*
98
+  TWBR: bit rate register
99
+  TWSR: status register (contains preselector bits)
100
+
101
+  prescalar
102
+    0		1
103
+    1		4
104
+    2		16
105
+    3		64
106
+
107
+  f = F_CPU/(16+2*TWBR*prescalar)
108
+  
109
+  F_CPU = 16MHz
110
+    TWBR = 152;
111
+    TWSR = 0;
112
+	--> 50KHz
113
+
114
+    TWBR = 72;
115
+    TWSR = 0;
116
+	--> 100KHz
117
+
118
+    F_CPU/(2*100000)-8  --> calculate TWBR value for 100KHz
119
+*/
120
+  TWSR = 0;
121
+  TWBR = F_CPU/(2*100000)-8;
122
+  u8g_i2c_clear_error();
123
+}
124
+
125
+uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos)
126
+{
127
+  volatile uint16_t cnt = 2000;	/* timout value should be > 280 for 50KHz Bus and 16 Mhz CPU, however the start condition might need longer */
128
+  while( !(TWCR & mask) )
129
+  {
130
+      if ( cnt == 0 )
131
+      {
132
+	u8g_i2c_set_error(U8G_I2C_ERR_TIMEOUT, pos);
133
+	return 0; /* error */
134
+      }
135
+      cnt--;
136
+    }
137
+  return 1;	/* all ok */
138
+}
139
+
140
+/* sla includes all 8 bits (with r/w bit), assums master transmit */
141
+uint8_t u8g_i2c_start(uint8_t sla)
142
+{
143
+  register uint8_t status;
144
+  
145
+  /* send start */
146
+  TWCR = _BV(TWINT) |  _BV(TWSTA)  |  _BV(TWEN);
147
+   
148
+  /* wait */
149
+  if ( u8g_i2c_wait(_BV(TWINT), 1) == 0 )
150
+    return 0;
151
+  
152
+  status = TW_STATUS;
153
+ 
154
+  /* check status after start */  
155
+  if ( status != TW_START && status != TW_REP_START )
156
+  {
157
+    u8g_i2c_set_error(U8G_I2C_ERR_BUS, 1);
158
+    return 0;
159
+  }
160
+
161
+  /* set slave address */  
162
+  TWDR = sla;
163
+  
164
+  /* enable sla transfer */
165
+  TWCR = _BV(TWINT)  |  _BV(TWEN);
166
+
167
+  /* wait */
168
+  if ( u8g_i2c_wait(_BV(TWINT), 2) == 0 )
169
+    return 0;
170
+  status = TW_STATUS;
171
+
172
+  /* check status after sla */  
173
+  if ( status != TW_MT_SLA_ACK )
174
+  {
175
+    u8g_i2c_set_error(U8G_I2C_ERR_BUS, 2);
176
+    return 0;
177
+  }
178
+
179
+   return 1;
180
+}
181
+
182
+uint8_t u8g_i2c_send_byte(uint8_t data)
183
+{
184
+  register uint8_t status;
185
+  TWDR = data;
186
+  TWCR = _BV(TWINT)  |  _BV(TWEN);
187
+  if ( u8g_i2c_wait(_BV(TWINT), 3) == 0 )
188
+    return 0;
189
+  status = TW_STATUS;
190
+  
191
+  if ( status != TW_MT_DATA_ACK )
192
+  {
193
+    u8g_i2c_set_error(U8G_I2C_ERR_BUS, 3);
194
+    return 0;
195
+  }
196
+  
197
+  return 1;  
198
+}
199
+
200
+void u8g_i2c_stop(void)
201
+{
202
+  /* write stop */
203
+  TWCR = _BV(TWINT) | _BV(TWEN) | _BV(TWSTO);
204
+
205
+  /* no error is checked for the stop condition */  
206
+  u8g_i2c_wait(_BV(TWSTO), 4);
207
+  
208
+}
209
+
210
+/*
211
+void twi_send(uint8_t adr, uint8_t data1, uint8_t data2)
212
+{
213
+  u8g_i2c_start(adr<<1);
214
+  u8g_i2c_send_byte(data1);
215
+  u8g_i2c_send_byte(data2);
216
+  u8g_i2c_stop();
217
+}
218
+*/
219
+
220
+#else
221
+
222
+/* empty interface */
223
+
224
+void u8g_i2c_init(uint8_t options)
225
+{
226
+  u8g_i2c_clear_error();
227
+}
228
+
229
+uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos)
230
+{
231
+  return 1;
232
+}
233
+
234
+uint8_t u8g_i2c_start(uint8_t sla)
235
+{
236
+  return 1;
237
+}
238
+uint8_t u8g_i2c_send_byte(uint8_t data)
239
+{
240
+  return 1;
241
+}
242
+
243
+void u8g_i2c_stop(void)
244
+{
245
+}
246
+
247
+
248
+#endif
249
+

+ 218
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_io.c View File

@@ -0,0 +1,218 @@
1
+/*
2
+  
3
+  u8g_com_io.c
4
+  
5
+  abstraction layer for low level i/o 
6
+
7
+  Universal 8bit Graphics Library
8
+  
9
+  Copyright (c) 2012, olikraus@gmail.com
10
+  All rights reserved.
11
+
12
+  Redistribution and use in source and binary forms, with or without modification, 
13
+  are permitted provided that the following conditions are met:
14
+
15
+  * Redistributions of source code must retain the above copyright notice, this list 
16
+    of conditions and the following disclaimer.
17
+    
18
+  * Redistributions in binary form must reproduce the above copyright notice, this 
19
+    list of conditions and the following disclaimer in the documentation and/or other 
20
+    materials provided with the distribution.
21
+
22
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
23
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
24
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
25
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
26
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
27
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
28
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
29
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
30
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
31
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
32
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
33
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
34
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
35
+  
36
+
37
+*/
38
+
39
+#include "u8g.h"
40
+
41
+#if defined(__AVR__)
42
+
43
+#include <avr/interrupt.h>
44
+#include <avr/io.h>
45
+
46
+typedef volatile uint8_t * IO_PTR;
47
+
48
+/* create internal pin number */
49
+uint8_t u8g_Pin(uint8_t port, uint8_t bitpos)
50
+{
51
+  port <<= 3;
52
+  port += bitpos;
53
+  return port;
54
+}
55
+
56
+const IO_PTR u8g_avr_ddr_P[] PROGMEM = {
57
+#ifdef DDRA
58
+  &DDRA,
59
+#else
60
+  0,
61
+#endif
62
+  &DDRB,
63
+#ifdef DDRC
64
+  &DDRC,
65
+#ifdef DDRD
66
+  &DDRD,
67
+#ifdef DDRE
68
+  &DDRE,
69
+#ifdef DDRF
70
+  &DDRF,
71
+#ifdef DDRG
72
+  &DDRG,
73
+#ifdef DDRH
74
+  &DDRH,
75
+#endif
76
+#endif
77
+#endif
78
+#endif
79
+#endif
80
+#endif
81
+};
82
+
83
+
84
+const IO_PTR u8g_avr_port_P[] PROGMEM = {
85
+#ifdef PORTA
86
+  &PORTA,
87
+#else
88
+  0,
89
+#endif
90
+  &PORTB,
91
+#ifdef PORTC
92
+  &PORTC,
93
+#ifdef PORTD
94
+  &PORTD,
95
+#ifdef PORTE
96
+  &PORTE,
97
+#ifdef PORTF
98
+  &PORTF,
99
+#ifdef PORTG
100
+  &PORTG,
101
+#ifdef PORTH
102
+  &PORTH,
103
+#endif
104
+#endif
105
+#endif
106
+#endif
107
+#endif
108
+#endif
109
+};
110
+
111
+const IO_PTR u8g_avr_pin_P[] PROGMEM = {
112
+#ifdef PINA
113
+  &PINA,
114
+#else
115
+  0,
116
+#endif
117
+  &PINB,
118
+#ifdef PINC
119
+  &PINC,
120
+#ifdef PIND
121
+  &PIND,
122
+#ifdef PINE
123
+  &PINE,
124
+#ifdef PINF
125
+  &PINF,
126
+#ifdef PING
127
+  &PING,
128
+#ifdef PINH
129
+  &PINH,
130
+#endif
131
+#endif
132
+#endif
133
+#endif
134
+#endif
135
+#endif
136
+};
137
+
138
+static volatile uint8_t *u8g_get_avr_io_ptr(const IO_PTR *base, uint8_t offset)
139
+{
140
+  volatile uint8_t * tmp;
141
+  base += offset;
142
+  memcpy_P(&tmp, base, sizeof(volatile uint8_t * PROGMEM));
143
+  return tmp; 
144
+}
145
+
146
+/* set direction to output of the specified pin (internal pin number) */
147
+void u8g_SetPinOutput(uint8_t internal_pin_number)
148
+{
149
+  *u8g_get_avr_io_ptr(u8g_avr_ddr_P, internal_pin_number>>3) |= _BV(internal_pin_number&7);
150
+}
151
+
152
+void u8g_SetPinInput(uint8_t internal_pin_number)
153
+{
154
+  *u8g_get_avr_io_ptr(u8g_avr_ddr_P, internal_pin_number>>3) &= ~_BV(internal_pin_number&7);
155
+}
156
+
157
+void u8g_SetPinLevel(uint8_t internal_pin_number, uint8_t level)
158
+{
159
+  volatile uint8_t * tmp = u8g_get_avr_io_ptr(u8g_avr_port_P, internal_pin_number>>3);
160
+  
161
+  if ( level == 0 )
162
+    *tmp &= ~_BV(internal_pin_number&7);
163
+  else
164
+    *tmp |= _BV(internal_pin_number&7);
165
+}
166
+
167
+uint8_t u8g_GetPinLevel(uint8_t internal_pin_number)
168
+{
169
+  volatile uint8_t * tmp = u8g_get_avr_io_ptr(u8g_avr_pin_P, internal_pin_number>>3);
170
+  if ( ((*tmp) & _BV(internal_pin_number&7))  != 0 )
171
+    return 1;
172
+  return 0;
173
+}
174
+
175
+#else
176
+
177
+uint8_t u8g_Pin(uint8_t port, uint8_t bitpos)
178
+{
179
+  port <<= 3;
180
+  port += bitpos;
181
+  return port;
182
+}
183
+
184
+void u8g_SetPinOutput(uint8_t internal_pin_number)
185
+{
186
+}
187
+
188
+void u8g_SetPinInput(uint8_t internal_pin_number)
189
+{
190
+}
191
+
192
+void u8g_SetPinLevel(uint8_t internal_pin_number, uint8_t level)
193
+{
194
+}
195
+
196
+uint8_t u8g_GetPinLevel(uint8_t internal_pin_number)
197
+{
198
+  return 0;
199
+}
200
+
201
+#endif
202
+
203
+
204
+void u8g_SetPIOutput(u8g_t *u8g, uint8_t pi)
205
+{
206
+  uint8_t pin;
207
+  pin = u8g->pin_list[pi];
208
+  if ( pin != U8G_PIN_NONE )
209
+    u8g_SetPinOutput(pin);
210
+}
211
+
212
+void u8g_SetPILevel(u8g_t *u8g, uint8_t pi, uint8_t level)
213
+{
214
+  uint8_t pin;
215
+  pin = u8g->pin_list[pi];
216
+  if ( pin != U8G_PIN_NONE )
217
+    u8g_SetPinLevel(pin, level);
218
+}

+ 63
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_null.c View File

@@ -0,0 +1,63 @@
1
+/*
2
+
3
+  u8g_com_null.c
4
+ 
5
+  communication null device
6
+
7
+  Universal 8bit Graphics Library
8
+ 
9
+  Copyright (c) 2011, olikraus@gmail.com
10
+  All rights reserved.
11
+
12
+  Redistribution and use in source and binary forms, with or without modification,
13
+  are permitted provided that the following conditions are met:
14
+
15
+  * Redistributions of source code must retain the above copyright notice, this list
16
+    of conditions and the following disclaimer.
17
+   
18
+  * Redistributions in binary form must reproduce the above copyright notice, this
19
+    list of conditions and the following disclaimer in the documentation and/or other
20
+    materials provided with the distribution.
21
+
22
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
23
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
24
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
27
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
32
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
34
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
35
+ 
36
+ 
37
+*/
38
+
39
+#include "u8g.h"
40
+
41
+uint8_t u8g_com_null_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
42
+{
43
+  switch(msg)
44
+  {
45
+    case U8G_COM_MSG_INIT:
46
+      break;
47
+    case U8G_COM_MSG_STOP:
48
+      break;
49
+
50
+   
51
+    case U8G_COM_MSG_CHIP_SELECT:
52
+      /* arg_val contains the chip number, which should be enabled */
53
+      break;
54
+
55
+
56
+    case U8G_COM_MSG_WRITE_BYTE:
57
+      break;
58
+    case U8G_COM_MSG_WRITE_SEQ:
59
+      break;
60
+  }
61
+  return 1;
62
+}
63
+

+ 99
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_cursor.c View File

@@ -0,0 +1,99 @@
1
+/*
2
+
3
+  u8g_cursor.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+  
35
+*/
36
+
37
+#include "u8g.h"
38
+
39
+void u8g_SetCursorFont(u8g_t *u8g, const u8g_pgm_uint8_t *cursor_font)
40
+{
41
+  u8g->cursor_font = cursor_font;
42
+}
43
+
44
+void u8g_SetCursorStyle(u8g_t *u8g, uint8_t encoding)
45
+{
46
+  u8g->cursor_encoding = encoding;
47
+}
48
+
49
+void u8g_SetCursorColor(u8g_t *u8g, uint8_t fg, uint8_t bg)
50
+{
51
+  u8g->cursor_bg_color = bg;
52
+  u8g->cursor_fg_color = fg;
53
+}
54
+
55
+void u8g_SetCursorPos(u8g_t *u8g, u8g_uint_t cursor_x, u8g_uint_t cursor_y)
56
+{
57
+  u8g->cursor_x = cursor_x;
58
+  u8g->cursor_y = cursor_y;
59
+}
60
+
61
+void u8g_EnableCursor(u8g_t *u8g)
62
+{
63
+    u8g->cursor_fn = u8g_DrawCursor;
64
+}
65
+
66
+void u8g_DisableCursor(u8g_t *u8g)
67
+{
68
+    u8g->cursor_fn = (u8g_draw_cursor_fn)0;
69
+}
70
+
71
+void u8g_DrawCursor(u8g_t *u8g)
72
+{
73
+  const u8g_pgm_uint8_t *font;
74
+  uint8_t color;
75
+  uint8_t encoding = u8g->cursor_encoding;
76
+  
77
+  /* get current values */
78
+  color = u8g_GetColorIndex(u8g);
79
+  font = u8g->font;
80
+  
81
+  /* draw cursor */
82
+  u8g->font = u8g->cursor_font;  
83
+  encoding++;
84
+  u8g_SetColorIndex(u8g, u8g->cursor_bg_color); 
85
+  /* 27. Jan 2013: replaced call to u8g_DrawGlyph with call to u8g_draw_glyph */
86
+  /* required, because y adjustment should not happen to the cursor fonts */
87
+  u8g_draw_glyph(u8g, u8g->cursor_x, u8g->cursor_y, encoding);
88
+  encoding--;
89
+  u8g_SetColorIndex(u8g, u8g->cursor_fg_color); 
90
+  /* 27. Jan 2013: replaced call to u8g_DrawGlyph with call to u8g_draw_glyph */
91
+  /* required, because y adjustment should not happen to the cursor fonts */
92
+  /* u8g_DrawGlyph(u8g, u8g->cursor_x, u8g->cursor_y, encoding); */
93
+  u8g_draw_glyph(u8g, u8g->cursor_x, u8g->cursor_y, encoding);
94
+  
95
+  /* restore previous values */
96
+  u8g->font = font;
97
+  u8g_SetColorIndex(u8g, color); 
98
+}
99
+

+ 215
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_delay.c View File

@@ -0,0 +1,215 @@
1
+/*
2
+
3
+  u8g_delay.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+  
35
+*/
36
+
37
+
38
+#include "u8g.h"
39
+
40
+/*==== Part 1: Derive suitable delay procedure ====*/
41
+
42
+#if defined(ARDUINO)
43
+#  if defined(__AVR__)
44
+#    define USE_AVR_DELAY
45
+#  elif defined(__PIC32MX)
46
+#    define USE_PIC32_DELAY
47
+#  elif defined(__arm__)		/* Arduino Due */
48
+#    define USE_ARDUINO_DELAY
49
+#  else
50
+#    define USE_ARDUINO_DELAY
51
+#  endif
52
+#elif defined(__AVR__)
53
+#  define USE_AVR_DELAY
54
+#elif defined(__18CXX)
55
+#  define USE_PIC18_DELAY
56
+#else
57
+#  define USE_DUMMY_DELAY
58
+#endif
59
+
60
+
61
+
62
+/*==== Part 2: Definition of the delay procedures ====*/
63
+
64
+/*== AVR Delay ==*/
65
+
66
+#if defined(USE_AVR_DELAY)
67
+#include <avr/interrupt.h>
68
+#include <avr/io.h>
69
+#include <util/delay.h>
70
+
71
+/*
72
+  Delay by the provided number of milliseconds.
73
+  Thus, a 16 bit value will allow a delay of 0..65 seconds
74
+  Makes use of the _delay_loop_2
75
+  
76
+  _delay_loop_2 will do a delay of n * 4 prozessor cycles.
77
+  with f = F_CPU cycles per second,
78
+  n = f / (1000 * 4 )
79
+  with f = 16000000 the result is 4000
80
+  with f = 1000000 the result is 250
81
+  
82
+  the millisec loop, gcc requires the following overhead:
83
+  - movev 1
84
+  - subwi 2x2
85
+  - bne i 2
86
+  ==> 7 cycles
87
+  ==> must be devided by 4, rounded up 7/4 = 2
88
+*/
89
+void u8g_Delay(uint16_t val)
90
+{
91
+  /* old version did a call to the arduino lib: delay(val); */
92
+  while( val != 0 )
93
+  {
94
+    _delay_loop_2( (F_CPU / 4000 ) -2);
95
+    val--;
96
+  }
97
+}
98
+
99
+/* delay by one micro second */
100
+void u8g_MicroDelay(void)
101
+{
102
+#if (F_CPU / 4000000 ) > 0 
103
+  _delay_loop_2( (F_CPU / 4000000 ) );
104
+#endif
105
+}
106
+
107
+/* delay by 10 micro seconds */
108
+void u8g_10MicroDelay(void)
109
+{
110
+#if (F_CPU / 400000 ) > 0 
111
+  _delay_loop_2( (F_CPU / 400000 ) );
112
+#endif
113
+}
114
+
115
+#endif 
116
+
117
+
118
+/*== Delay for PIC18 (not tested) ==*/
119
+
120
+#if defined(USE_PIC18_DELAY)
121
+#include <delays.h>
122
+#define GetSystemClock()		(64000000ul)      // Hz
123
+#define GetInstructionClock()	(GetSystemClock()/4)
124
+
125
+void u8g_Delay(uint16_t val)
126
+{/*
127
+	unsigned int _iTemp = (val);
128
+	while(_iTemp--)		
129
+		Delay1KTCYx((GetInstructionClock()+999999)/1000000);
130
+		*/
131
+}
132
+void u8g_MicroDelay(void)
133
+{
134
+  /* not implemented */
135
+}
136
+void u8g_10MicroDelay(void)
137
+{
138
+  /* not implemented */
139
+}
140
+#endif
141
+
142
+
143
+/*== Arduino Delay ==*/
144
+#if defined(USE_ARDUINO_DELAY)
145
+void u8g_Delay(uint16_t val)
146
+{
147
+	delay(val);
148
+}
149
+void u8g_MicroDelay(void)
150
+{
151
+	delayMicroseconds(1);
152
+}
153
+void u8g_10MicroDelay(void)
154
+{
155
+	delayMicroseconds(10);
156
+}
157
+#endif
158
+
159
+#if defined(USE_PIC32_DELAY)
160
+/* 
161
+  Assume chipkit here with F_CPU correctly defined
162
+  The problem was, that u8g_Delay() is called within the constructor.
163
+  It seems that the chipkit is not fully setup at this time, so a
164
+  call to delay() will not work. So here is my own implementation.
165
+
166
+*/
167
+#define CPU_COUNTS_PER_SECOND (F_CPU/2UL)
168
+#define TICKS_PER_MILLISECOND  (CPU_COUNTS_PER_SECOND/1000UL)
169
+#include "plib.h"
170
+void u8g_Delay(uint16_t val)
171
+{
172
+	uint32_t d;
173
+	uint32_t s;
174
+	d = val;
175
+	d *= TICKS_PER_MILLISECOND;
176
+	s = ReadCoreTimer();
177
+	while ( (uint32_t)(ReadCoreTimer() - s) < d )
178
+		;
179
+} 
180
+
181
+void u8g_MicroDelay(void)
182
+{
183
+	uint32_t d;
184
+	uint32_t s;
185
+	d = TICKS_PER_MILLISECOND/1000;
186
+	s = ReadCoreTimer();
187
+	while ( (uint32_t)(ReadCoreTimer() - s) < d )
188
+		;
189
+} 
190
+
191
+void u8g_10MicroDelay(void)
192
+{
193
+	uint32_t d;
194
+	uint32_t s;
195
+	d = TICKS_PER_MILLISECOND/100;
196
+	s = ReadCoreTimer();
197
+	while ( (uint32_t)(ReadCoreTimer() - s) < d )
198
+		;
199
+} 
200
+
201
+#endif
202
+
203
+/*== Any other systems: Dummy Delay ==*/
204
+#if defined(USE_DUMMY_DELAY)
205
+void u8g_Delay(uint16_t val)
206
+{
207
+	/* do not know how to delay... */
208
+}
209
+void u8g_MicroDelay(void)
210
+{
211
+}
212
+void u8g_10MicroDelay(void)
213
+{
214
+}
215
+#endif

+ 92
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_flipdisc_2x7.c View File

@@ -0,0 +1,92 @@
1
+/*
2
+
3
+  u8g_dev_flipdisc.c
4
+  
5
+  1-Bit (BW) Driver for flip disc matrix
6
+  2x 7 pixel height
7
+
8
+  Universal 8bit Graphics Library
9
+  
10
+  Copyright (c) 2011, olikraus@gmail.com
11
+  All rights reserved.
12
+
13
+  Redistribution and use in source and binary forms, with or without modification, 
14
+  are permitted provided that the following conditions are met:
15
+
16
+  * Redistributions of source code must retain the above copyright notice, this list 
17
+    of conditions and the following disclaimer.
18
+    
19
+  * Redistributions in binary form must reproduce the above copyright notice, this 
20
+    list of conditions and the following disclaimer in the documentation and/or other 
21
+    materials provided with the distribution.
22
+
23
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
24
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
25
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
26
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
27
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
28
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
29
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
30
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
31
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
32
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
33
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
34
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
35
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
36
+  
37
+*/
38
+
39
+#include "u8g.h"
40
+
41
+#define WIDTH 28
42
+#define HEIGHT 14
43
+#define PAGE_HEIGHT 14
44
+
45
+/*
46
+  Write data to the flip disc matrix.
47
+  This procedure must be implemented by the user.
48
+  Arguments:
49
+    id:	Id for the matrix. Currently always 0.
50
+    page: 	A page has a height of 14 pixel. For a matrix with HEIGHT == 14 this will be always 0
51
+    width: 	The width of the flip disc matrix. Always equal to WIDTH
52
+    row1: 	first data line (7 pixel per byte)
53
+    row2: 	first data line (7 pixel per byte)
54
+*/
55
+void writeFlipDiscMatrix(uint8_t id, uint8_t page, uint8_t width, uint8_t *row1, uint8_t *row2);
56
+
57
+
58
+
59
+void (*u8g_write_flip_disc_matrix)(uint8_t id, uint8_t page, uint8_t width, uint8_t *row1, uint8_t *row2);
60
+
61
+void u8g_SetFlipDiscCallback(u8g_t *u8g, void (*cb)(uint8_t id, uint8_t page, uint8_t width, uint8_t *row1, uint8_t *row2))
62
+{
63
+  u8g_write_flip_disc_matrix = cb;
64
+}
65
+
66
+uint8_t u8g_dev_flipdisc_2x7_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
67
+{
68
+  switch(msg)
69
+  {
70
+    case U8G_DEV_MSG_INIT:
71
+      break;
72
+    case U8G_DEV_MSG_STOP:
73
+      break;
74
+    case U8G_DEV_MSG_PAGE_NEXT:
75
+      {
76
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
77
+        
78
+	/* current page: pb->p.page */
79
+	/* ptr to the buffer: pb->buf */
80
+	
81
+	(*u8g_write_flip_disc_matrix)(0, pb->p.page, WIDTH, pb->buf, pb->buf+WIDTH);
82
+      }
83
+      break;
84
+    case U8G_DEV_MSG_CONTRAST:
85
+      return 1;
86
+  }
87
+  return u8g_dev_pb14v1_base_fn(u8g, dev, msg, arg);
88
+}
89
+
90
+uint8_t u8g_dev_flipdisc_2x7_bw_buf[WIDTH*2] U8G_NOCOMMON ; 
91
+u8g_pb_t u8g_dev_flipdisc_2x7_bw_pb = { {16, HEIGHT, 0, 0, 0},  WIDTH, u8g_dev_flipdisc_2x7_bw_buf}; 
92
+u8g_dev_t u8g_dev_flipdisc_2x7 = { u8g_dev_flipdisc_2x7_bw_fn, &u8g_dev_flipdisc_2x7_bw_pb, u8g_com_null_fn };

+ 130
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_gprof.c View File

@@ -0,0 +1,130 @@
1
+/*
2
+
3
+  u8g_dev_gprof.c
4
+
5
+  Device for performance measurement with gprof.
6
+  Does not write any data, but uses a buffer.
7
+
8
+  Universal 8bit Graphics Library
9
+  
10
+  Copyright (c) 2011, olikraus@gmail.com
11
+  All rights reserved.
12
+
13
+  Redistribution and use in source and binary forms, with or without modification, 
14
+  are permitted provided that the following conditions are met:
15
+
16
+  * Redistributions of source code must retain the above copyright notice, this list 
17
+    of conditions and the following disclaimer.
18
+    
19
+  * Redistributions in binary form must reproduce the above copyright notice, this 
20
+    list of conditions and the following disclaimer in the documentation and/or other 
21
+    materials provided with the distribution.
22
+
23
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
24
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
25
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
26
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
27
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
28
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
29
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
30
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
31
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
32
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
33
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
34
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
35
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
36
+  
37
+  
38
+
39
+*/
40
+
41
+#include "u8g.h"
42
+
43
+
44
+#define WIDTH 128
45
+#define HEIGHT 64
46
+#define PAGE_HEIGHT 8
47
+
48
+uint8_t u8g_dev_gprof_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
49
+
50
+uint8_t u8g_pb_dev_gprof_buf[WIDTH];
51
+u8g_pb_t u8g_pb_dev_gprof = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0},  WIDTH, u8g_pb_dev_gprof_buf };
52
+
53
+u8g_dev_t u8g_dev_gprof = { u8g_dev_gprof_fn, &u8g_pb_dev_gprof, NULL };
54
+
55
+uint8_t u8g_dev_gprof_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
56
+{
57
+  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
58
+  
59
+  switch(msg)
60
+  {
61
+    case U8G_DEV_MSG_INIT:
62
+      break;
63
+    case U8G_DEV_MSG_STOP:
64
+      break;
65
+    case U8G_DEV_MSG_PAGE_FIRST:
66
+      u8g_pb_Clear(pb);
67
+      u8g_page_First(&(pb->p));
68
+      break;
69
+    case U8G_DEV_MSG_PAGE_NEXT:
70
+      /*
71
+      {
72
+        uint8_t i, j;
73
+        uint8_t page_height;
74
+        page_height = pb->p.page_y1;
75
+        page_height -= pb->p.page_y0;
76
+        page_height++;
77
+        for( j = 0; j < page_height; j++ )
78
+        {
79
+          printf("%02d ", j);
80
+          for( i = 0; i < WIDTH; i++ )
81
+          {
82
+            if ( (u8g_pb_dev_stdout_buf[i] & (1<<j)) != 0 )
83
+              printf("#");
84
+            else
85
+              printf(".");
86
+          }
87
+          printf("\n");
88
+        }
89
+      }
90
+      */
91
+      if ( u8g_page_Next(&(pb->p)) == 0 )
92
+      {
93
+        //printf("\n");
94
+        return 0;
95
+      }
96
+      u8g_pb_Clear(pb);
97
+      break;
98
+#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
99
+    case U8G_DEV_MSG_IS_BBX_INTERSECTION:
100
+       {
101
+        u8g_dev_arg_bbx_t *bbx = (u8g_dev_arg_bbx_t *)arg;
102
+        u8g_uint_t x2, y2;
103
+
104
+        y2 = bbx->y;
105
+        y2 += bbx->h;
106
+        y2--;
107
+        
108
+        if ( u8g_pb_IsYIntersection(pb, bbx->y, y2) == 0 )
109
+          return 0;
110
+        
111
+        /* maybe this one can be skiped... probability is very high to have an intersection, so it would be ok to always return 1 */
112
+        x2 = bbx->x;
113
+        x2 += bbx->w;
114
+        x2--;
115
+        
116
+        if ( u8g_pb_IsXIntersection(pb, bbx->x, x2) == 0 )
117
+          return 0;
118
+      }
119
+      return 1;
120
+#endif
121
+    case U8G_DEV_MSG_GET_PAGE_BOX:
122
+      u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
123
+      break;
124
+    case U8G_DEV_MSG_SET_COLOR_INDEX:
125
+      break;
126
+    case U8G_DEV_MSG_SET_XY_CB:
127
+      break;
128
+  }
129
+  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
130
+}

+ 326
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ili9325d_320x240.c View File

@@ -0,0 +1,326 @@
1
+/*
2
+
3
+  u8g_dev_ili9325d_320x240.c
4
+  
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+
34
+  Color format
35
+    Red: 5 Bit
36
+    Green: 6 Bit
37
+    Blue: 5 Bit
38
+  
39
+    
40
+*/
41
+
42
+#include "u8g.h"
43
+
44
+#define WIDTH 240
45
+
46
+#if defined(U8G_16BIT)
47
+#define HEIGHT 320
48
+#else
49
+/* if the user tries to compile the 8Bit version of the lib, then restrict the height to something which fits to 8Bit */
50
+#define HEIGHT 240
51
+#endif
52
+#define PAGE_HEIGHT 4
53
+
54
+
55
+/*
56
+  reference board for this device:
57
+    http://iteadstudio.com/store/index.php?main_page=product_info&cPath=57_58&products_id=55
58
+  documentation:
59
+    http://iteadstudio.com/Downloadfile/ITDB02_material.rar
60
+  datasheet
61
+    http://www.newhavendisplay.com/app_notes/ILI9325D.pdf
62
+  other libs
63
+    http://henningkarlsen.com/electronics/library.php
64
+  init sequence
65
+    http://code.google.com/p/itdb02/, ITDB02.cpp, iteadstudio.com
66
+*/
67
+
68
+static const uint8_t u8g_dev_ili9325d_320x240_init_seq[] PROGMEM = {
69
+  U8G_ESC_CS(0),             /* disable chip */
70
+  U8G_ESC_DLY(50),         /* delay 50 ms */
71
+  U8G_ESC_RST(15),           /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
72
+  U8G_ESC_DLY(50),         /* delay 50 ms */
73
+  U8G_ESC_RST(15),           /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
74
+  U8G_ESC_DLY(50),         /* delay 50 ms */
75
+  U8G_ESC_CS(1),             /* enable chip */
76
+  U8G_ESC_DLY(50),         /* delay 50 ms */
77
+
78
+  
79
+  //U8G_ESC_ADR(0),  0x000, 0x0E5,               /* only used for none D version: set SRAM internal timing */
80
+  //U8G_ESC_ADR(1),  0x078, 0x0f0,             
81
+  U8G_ESC_ADR(0),  0x000, 0x001,               /* Driver Output Control, bits 8 & 10 */
82
+  U8G_ESC_ADR(1),  0x001, 0x000,           
83
+  U8G_ESC_ADR(0),  0x000, 0x002,               /* LCD Driving Wave Control, bit 9: Set line inversion */
84
+  U8G_ESC_ADR(1),  0x002, 0x000,               /* ITDB02 none D verion: 0x007, 0x000 */        
85
+  U8G_ESC_ADR(0),  0x000, 0x003,               /* Entry Mode, GRAM write direction and BGR=1 */
86
+  U8G_ESC_ADR(1),  0x010, 0x030,           
87
+  U8G_ESC_ADR(0),  0x000, 0x004,               /* Resize register */
88
+  U8G_ESC_ADR(1),  0x000, 0x000,           
89
+  U8G_ESC_ADR(0),  0x000, 0x008,               /* Display Control 2: set the back porch and front porch */
90
+  U8G_ESC_ADR(1),  0x002, 0x007,           
91
+  
92
+  U8G_ESC_ADR(0),  0x000, 0x009,               /* Display Control 3 */
93
+  U8G_ESC_ADR(1),  0x000, 0x000,           
94
+
95
+  U8G_ESC_ADR(0),  0x000, 0x00a,               /* Display Control 4: FMARK */
96
+  U8G_ESC_ADR(1),  0x000, 0x000,           
97
+  U8G_ESC_ADR(0),  0x000, 0x00c,               /* RGB Display Interface Control 1 */
98
+  U8G_ESC_ADR(1),  0x000, 0x000,           
99
+  U8G_ESC_ADR(0),  0x000, 0x00d,               /* Frame Maker Position */
100
+  U8G_ESC_ADR(1),  0x000, 0x000,           
101
+  U8G_ESC_ADR(0),  0x000, 0x00f,                /* RGB Display Interface Control 2 */
102
+  U8G_ESC_ADR(1),  0x000, 0x000,  
103
+  U8G_ESC_ADR(0),  0x000, 0x010,               /* Power Control 1: SAP, BT[3:0], AP, DSTB, SLP, STB */
104
+  U8G_ESC_ADR(1),  0x000, 0x000,  
105
+  U8G_ESC_ADR(0),  0x000, 0x011,               /* Power Control 2: DC1[2:0], DC0[2:0], VC[2:0] */
106
+  U8G_ESC_ADR(1),  0x000, 0x007,  
107
+  U8G_ESC_ADR(0),  0x000, 0x012,               /* Power Control 3: VREG1OUT voltage */
108
+  U8G_ESC_ADR(1),  0x000, 0x000,  
109
+  U8G_ESC_ADR(0),  0x000, 0x013,               /* Power Control 4: VDV[4:0] for VCOM amplitude */
110
+  U8G_ESC_ADR(1),  0x000, 0x000,  
111
+  U8G_ESC_ADR(0),  0x000, 0x007,               /* Display Control 1: Operate, but do not display */
112
+  U8G_ESC_ADR(1),  0x000, 0x001,   
113
+  
114
+  U8G_ESC_DLY(100),         /* delay 100 ms */  /*  ITDB02 none D verion:  50ms */
115
+  U8G_ESC_DLY(100),         /* delay 100 ms */
116
+  
117
+  U8G_ESC_ADR(0),  0x000, 0x010,               /* Power Control 1: SAP, BT[3:0], AP, DSTB, SLP, STB */
118
+  U8G_ESC_ADR(1),  0x016, 0x090,               /*  ITDB02 none D verion:  0x010, 0x090 */
119
+  U8G_ESC_ADR(0),  0x000, 0x011,               /* Power Control 2: SAP, BT[3:0], AP, DSTB, SLP, STB */
120
+  U8G_ESC_ADR(1),  0x002, 0x027,
121
+
122
+  U8G_ESC_DLY(50),         /* delay 50 ms */
123
+  
124
+  U8G_ESC_ADR(0),  0x000, 0x012,               /* Power Control 3: VCI: External, VCI*1.80 */
125
+  U8G_ESC_ADR(1),  0x000, 0x00d,               /*  ITDB02 none D verion:  0x000, 0x01f */
126
+
127
+  U8G_ESC_DLY(50),         /* delay 50 ms */
128
+  
129
+  U8G_ESC_ADR(0),  0x000, 0x013,               /* Power Control 4: VDV[4:0] for VCOM amplitude */
130
+  U8G_ESC_ADR(1),  0x012, 0x000,               /*  ITDB02 none D verion:  0x015, 0x000 */
131
+  U8G_ESC_ADR(0),  0x000, 0x029,               /* Power Control 7 */
132
+  U8G_ESC_ADR(1),  0x000, 0x00a,               /*  ITDB02 none D verion:  0x000, 0x027 */
133
+  U8G_ESC_ADR(0),  0x000, 0x02b,               /* Frame Rate: 83 */
134
+  U8G_ESC_ADR(1),  0x000, 0x00d,
135
+
136
+  U8G_ESC_DLY(50),         /* delay 50 ms */
137
+  
138
+  U8G_ESC_ADR(0),  0x000, 0x020,               /* Horizontal GRAM Address Set */
139
+  U8G_ESC_ADR(1),  0x000, 0x000,
140
+  U8G_ESC_ADR(0),  0x000, 0x021,               /* Vertical GRAM Address Set */
141
+  U8G_ESC_ADR(1),  0x000, 0x000,
142
+
143
+  /* gamma control */
144
+  U8G_ESC_ADR(0),  0x000, 0x030,               
145
+  U8G_ESC_ADR(1),  0x000, 0x000,
146
+  U8G_ESC_ADR(0),  0x000, 0x031,
147
+  U8G_ESC_ADR(1),  0x004, 0x004,
148
+  U8G_ESC_ADR(0),  0x000, 0x032,
149
+  U8G_ESC_ADR(1),  0x000, 0x003,
150
+  U8G_ESC_ADR(0),  0x000, 0x035,               
151
+  U8G_ESC_ADR(1),  0x004, 0x005,
152
+  U8G_ESC_ADR(0),  0x000, 0x036,               
153
+  U8G_ESC_ADR(1),  0x008, 0x008,
154
+  U8G_ESC_ADR(0),  0x000, 0x037,               
155
+  U8G_ESC_ADR(1),  0x004, 0x007,
156
+  U8G_ESC_ADR(0),  0x000, 0x038,               
157
+  U8G_ESC_ADR(1),  0x003, 0x003,
158
+  U8G_ESC_ADR(0),  0x000, 0x039,               
159
+  U8G_ESC_ADR(1),  0x007, 0x007,
160
+  U8G_ESC_ADR(0),  0x000, 0x03c,               
161
+  U8G_ESC_ADR(1),  0x005, 0x004,
162
+  U8G_ESC_ADR(0),  0x000, 0x03d,               
163
+  U8G_ESC_ADR(1),  0x008, 0x008,
164
+  
165
+  U8G_ESC_ADR(0),  0x000, 0x050,               /* Horizontal GRAM Start Address */
166
+  U8G_ESC_ADR(1),  0x000, 0x000,
167
+  U8G_ESC_ADR(0),  0x000, 0x051,               /* Horizontal GRAM End Address: 239 */
168
+  U8G_ESC_ADR(1),  0x000, 0x0EF,
169
+  U8G_ESC_ADR(0),  0x000, 0x052,               /* Vertical GRAM Start Address */
170
+  U8G_ESC_ADR(1),  0x000, 0x000,
171
+  U8G_ESC_ADR(0),  0x000, 0x053,               /* Vertical GRAM End Address: 319 */
172
+  U8G_ESC_ADR(1),  0x001, 0x03F,
173
+  
174
+  U8G_ESC_ADR(0),  0x000, 0x060,               /* Driver Output Control 2 */
175
+  U8G_ESC_ADR(1),  0x0a7, 0x000,
176
+  U8G_ESC_ADR(0),  0x000, 0x061,               /* Base Image Display Control: NDL,VLE, REV */
177
+  U8G_ESC_ADR(1),  0x000, 0x001,
178
+  U8G_ESC_ADR(0),  0x000, 0x06a,               /* Vertical Scroll Control */
179
+  U8G_ESC_ADR(1),  0x000, 0x000,
180
+
181
+  U8G_ESC_ADR(0),  0x000, 0x080,               /* Partial Image 1 Display Position */
182
+  U8G_ESC_ADR(1),  0x000, 0x000,
183
+  U8G_ESC_ADR(0),  0x000, 0x081,               /* Partial Image 1 RAM Start Address */
184
+  U8G_ESC_ADR(1),  0x000, 0x000,
185
+  U8G_ESC_ADR(0),  0x000, 0x082,               /* Partial Image 1 RAM End Address */
186
+  U8G_ESC_ADR(1),  0x000, 0x000,
187
+  U8G_ESC_ADR(0),  0x000, 0x083,               /* Partial Image 2 Display Position */
188
+  U8G_ESC_ADR(1),  0x000, 0x000,
189
+  U8G_ESC_ADR(0),  0x000, 0x084,               /* Partial Image 2 RAM Start Address */
190
+  U8G_ESC_ADR(1),  0x000, 0x000,
191
+  U8G_ESC_ADR(0),  0x000, 0x085,               /* Partial Image 2 RAM End Address */
192
+  U8G_ESC_ADR(1),  0x000, 0x000,
193
+
194
+  U8G_ESC_ADR(0),  0x000, 0x090,               /* Panel Interface Control 1 */
195
+  U8G_ESC_ADR(1),  0x000, 0x010,
196
+  U8G_ESC_ADR(0),  0x000, 0x092,               /* Panel Interface Control 2 */
197
+  U8G_ESC_ADR(1),  0x000, 0x000,        /* 0x006, 0x000 */
198
+
199
+  U8G_ESC_ADR(0),  0x000, 0x007,               /* Display Control 1: Operate, display ON */
200
+  U8G_ESC_ADR(1),  0x001, 0x033,   
201
+
202
+  U8G_ESC_DLY(10),               /* delay 10 ms */
203
+  
204
+  /* write test pattern */  
205
+  U8G_ESC_ADR(0),  0x000, 0x020,               /* Horizontal GRAM Address Set */
206
+  U8G_ESC_ADR(1),  0x000, 0x000,
207
+  U8G_ESC_ADR(0),  0x000, 0x021,               /* Vertical GRAM Address Set */
208
+  U8G_ESC_ADR(1),  0x000, 0x010,
209
+  U8G_ESC_ADR(0),  0x000, 0x022,               /* Write Data to GRAM */
210
+  U8G_ESC_ADR(1),  0x0fe, 0x0fe,
211
+  0x000, 0x000,
212
+  0x0fe, 0x0fe,
213
+  0x000, 0x000,
214
+  0x0fe, 0x0fe,
215
+  0x000, 0x000,
216
+  0x0fe, 0x0fe,
217
+  0x000, 0x000,
218
+  0x0fe, 0x0fe,
219
+  0x000, 0x000,
220
+  0x0fe, 0x0fe,
221
+  0x000, 0x000,
222
+  0x0fe, 0x0fe,
223
+  0x000, 0x000,
224
+  0x0fe, 0x0fe,
225
+  0x000, 0x000,
226
+  0x0fe, 0x0fe,
227
+  
228
+  U8G_ESC_CS(0),             /* disable chip */
229
+  U8G_ESC_END                /* end of sequence */
230
+};
231
+
232
+
233
+static const uint8_t u8g_dev_ili9325d_320x240_page_seq[] PROGMEM = {
234
+  U8G_ESC_CS(1),             /* enable chip */
235
+  U8G_ESC_ADR(0),  0x000, 0x020,               /* Horizontal GRAM Address Set */
236
+  U8G_ESC_ADR(1),  0x000, 0x000,
237
+  U8G_ESC_ADR(0),  0x000, 0x021,               /* Vertical GRAM Address Set */
238
+  U8G_ESC_ADR(1), 
239
+  U8G_ESC_END                /* end of sequence */
240
+};
241
+
242
+/* convert the internal RGB 332 to 65K high byte */
243
+static uint8_t u8g_dev_ili9325d_get_65K_high_byte(uint8_t color)
244
+{
245
+  uint8_t h;
246
+  h = color;
247
+  h &= 0x0e0;
248
+  h |= h>>3;
249
+  h &= 0x0f8;
250
+  color>>=2;
251
+  color &= 7;
252
+  h |= color;
253
+  return h;  
254
+}
255
+
256
+/* convert the internal RGB 332 to 65K high byte */
257
+static uint8_t u8g_dev_ili9325d_get_65K_low_byte(uint8_t color)
258
+{
259
+  uint8_t l;
260
+  l = color;
261
+  l <<= 3;
262
+  color &= 3;
263
+  color <<= 1;
264
+  l |= color;
265
+  return l;  
266
+}
267
+
268
+
269
+uint8_t u8g_dev_ili9325d_320x240_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
270
+{
271
+  
272
+  switch(msg)
273
+  {
274
+    case U8G_DEV_MSG_INIT:
275
+      u8g_InitCom(u8g, dev);
276
+      //for(;;)
277
+        u8g_WriteEscSeqP(u8g, dev, u8g_dev_ili9325d_320x240_init_seq);
278
+    
279
+      break;
280
+    case U8G_DEV_MSG_STOP:
281
+      break;
282
+    case U8G_DEV_MSG_PAGE_NEXT:
283
+      {
284
+        uint8_t i;
285
+        uint16_t y, j;
286
+        uint8_t *ptr;
287
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
288
+        
289
+        y = pb->p.page_y0;
290
+        ptr = pb->buf;
291
+        for( i = 0; i < pb->p.page_height; i ++ )
292
+        {
293
+          u8g_WriteEscSeqP(u8g, dev, u8g_dev_ili9325d_320x240_page_seq);
294
+          u8g_WriteByte(u8g, dev, y >> 8 );      /* display ram (cursor) address high byte */
295
+          u8g_WriteByte(u8g, dev, y & 255 );      /* display ram (cursor) address low byte */
296
+
297
+          u8g_SetAddress(u8g, dev, 0);           /* cmd mode */
298
+          u8g_WriteByte(u8g, dev, 0 );  
299
+          u8g_WriteByte(u8g, dev, 0x022 );      /* start gram data */  
300
+          
301
+          u8g_SetAddress(u8g, dev, 1);           /* data mode */
302
+          
303
+          for( j = 0; j < pb->width; j++ )
304
+          {
305
+            u8g_WriteByte(u8g, dev, u8g_dev_ili9325d_get_65K_high_byte(*ptr) );  
306
+            u8g_WriteByte(u8g, dev, u8g_dev_ili9325d_get_65K_low_byte(*ptr) );  
307
+              
308
+            ptr++;
309
+          }
310
+          y++;
311
+        }
312
+        u8g_SetChipSelect(u8g, dev, 0);
313
+      }
314
+      break;
315
+  }
316
+  return u8g_dev_pb8h8_base_fn(u8g, dev, msg, arg);
317
+}
318
+
319
+uint8_t u8g_ili9325d_320x240_8h8_buf[WIDTH*PAGE_HEIGHT] U8G_NOCOMMON ; 
320
+u8g_pb_t u8g_ili9325d_320x240_8h8_pb U8G_NOCOMMON = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0},  WIDTH, u8g_ili9325d_320x240_8h8_buf}; 
321
+u8g_dev_t u8g_dev_ili9325d_320x240_8bit U8G_NOCOMMON = { u8g_dev_ili9325d_320x240_fn, &u8g_ili9325d_320x240_8h8_pb, u8g_com_arduino_port_d_wr_fn };
322
+//u8g_dev_t u8g_dev_ili9325d_320x240_8bit = { u8g_dev_ili9325d_320x240_fn, &u8g_ili9325d_320x240_8h8_pb, u8g_com_arduino_parallel_fn };
323
+
324
+//U8G_PB_DEV(u8g_dev_ili9325d_320x240_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ili9325d_320x240_fn, U8G_COM_PARALLEL);
325
+
326
+

+ 110
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ks0108_128x64.c View File

@@ -0,0 +1,110 @@
1
+/*
2
+
3
+  u8g_dev_ks0108_128x64.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+
35
+  ADDRESS = 0   (Command Mode)
36
+    0x03f       Display On
37
+    0x0c0       Start Display at line 0
38
+    0x040 | y   write to y address (y:0..63)
39
+    0x0b8 | x   write to page [0..7]
40
+
41
+
42
+  u8g_Init8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, en, cs1, cs2, di, rw, reset)
43
+  u8g_Init8Bit(u8g, dev,  8,    9, 10, 11,   4,   5,   6,   7, 18, 14, 15, 17, 16, U8G_PIN_NONE)
44
+  
45
+*/
46
+
47
+#include "u8g.h"
48
+
49
+#define WIDTH 128
50
+#define HEIGHT 64
51
+#define PAGE_HEIGHT 8
52
+
53
+static const uint8_t u8g_dev_ks0108_128x64_init_seq[] PROGMEM = {
54
+  U8G_ESC_CS(0),             /* disable chip */
55
+  U8G_ESC_ADR(0),           /* instruction mode */
56
+  U8G_ESC_RST(1),           /* do reset low pulse with (1*16)+2 milliseconds */
57
+  U8G_ESC_CS(1),             /* enable chip 1 */
58
+  0x03f,		                /* display on */
59
+  0x0c0,		                /* start at line 0 */
60
+  U8G_ESC_DLY(20),         /* delay 20 ms */
61
+  U8G_ESC_CS(2),             /* enable chip 2 */
62
+  0x03f,		                /* display on */
63
+  0x0c0,		                /* start at line 0 */
64
+  U8G_ESC_DLY(20),         /* delay 20 ms */
65
+  U8G_ESC_CS(0),             /* disable all chips */
66
+  U8G_ESC_END                /* end of sequence */
67
+};
68
+
69
+
70
+uint8_t u8g_dev_ks0108_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
71
+{
72
+  
73
+  switch(msg)
74
+  {
75
+    case U8G_DEV_MSG_INIT:
76
+      u8g_InitCom(u8g, dev);
77
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ks0108_128x64_init_seq);
78
+      break;
79
+    case U8G_DEV_MSG_STOP:
80
+      break;
81
+    case U8G_DEV_MSG_PAGE_NEXT:
82
+      {
83
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
84
+        
85
+        u8g_SetAddress(u8g, dev, 0);           /* command mode */
86
+        u8g_SetChipSelect(u8g, dev, 2);
87
+        u8g_WriteByte(u8g, dev, 0x0b8 | pb->p.page); /* select current page (KS0108b) */
88
+        u8g_WriteByte(u8g, dev, 0x040 );		/* set address 0 */
89
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
90
+        u8g_WriteSequence(u8g, dev, 64, pb->buf);
91
+        u8g_SetChipSelect(u8g, dev, 0);
92
+        
93
+        u8g_SetAddress(u8g, dev, 0);           /* command mode */
94
+        u8g_SetChipSelect(u8g, dev, 1);
95
+        u8g_WriteByte(u8g, dev, 0x0b8 | pb->p.page); /* select current page (KS0108b) */
96
+        u8g_WriteByte(u8g, dev, 0x040 );		/* set address 0 */
97
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
98
+        u8g_WriteSequence(u8g, dev, 64, 64+(uint8_t *)pb->buf);
99
+        u8g_SetChipSelect(u8g, dev, 0);
100
+        
101
+      }
102
+      break;
103
+  }
104
+  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
105
+}
106
+
107
+U8G_PB_DEV(u8g_dev_ks0108_128x64, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ks0108_128x64_fn, U8G_COM_PARALLEL);
108
+U8G_PB_DEV(u8g_dev_ks0108_128x64_fast, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ks0108_128x64_fn, U8G_COM_FAST_PARALLEL);
109
+
110
+

+ 147
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_lc7981_160x80.c View File

@@ -0,0 +1,147 @@
1
+/*
2
+
3
+  u8g_dev_lc7981_160x80.c
4
+  
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+  
35
+*/
36
+
37
+#include "u8g.h"
38
+
39
+#define WIDTH 160
40
+#define HEIGHT 80
41
+#define PAGE_HEIGHT 8
42
+
43
+
44
+/*
45
+  code ideas: 
46
+  https://github.com/vsergeev/embedded-drivers/tree/master/avr-lc7981
47
+  data sheets:
48
+  http://www.lcd-module.de/eng/pdf/zubehoer/lc7981.pdf
49
+  http://www.lcd-module.de/pdf/grafik/w160-6.pdf
50
+*/
51
+
52
+static const uint8_t u8g_dev_lc7981_160x80_init_seq[] PROGMEM = {
53
+  U8G_ESC_CS(0),             /* disable chip */
54
+  U8G_ESC_ADR(1),           /* instruction mode */
55
+  U8G_ESC_RST(15),           /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
56
+  U8G_ESC_CS(1),             /* enable chip */
57
+  U8G_ESC_DLY(50),         /* delay 50 ms */
58
+  
59
+  
60
+  U8G_ESC_ADR(1),               /* instruction mode */
61
+  0x000,                                /* mode register */
62
+  U8G_ESC_ADR(0),               /* data mode */
63
+  0x032,                                /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1)*/
64
+
65
+  U8G_ESC_ADR(1),               /* instruction mode */
66
+  0x001,                                /* character/bits per pixel pitch */
67
+  U8G_ESC_ADR(0),               /* data mode */
68
+  0x007,                                /* 8 bits per pixel */
69
+
70
+  U8G_ESC_ADR(1),               /* instruction mode */
71
+  0x002,                                /* number of chars/byte width of the screen */
72
+  U8G_ESC_ADR(0),               /* data mode */
73
+  WIDTH/8-1,                         /* 8 bits per pixel */
74
+
75
+  U8G_ESC_ADR(1),               /* instruction mode */
76
+  0x003,                                /* time division */
77
+  U8G_ESC_ADR(0),               /* data mode */
78
+  0x07f,                                /*  */
79
+
80
+  U8G_ESC_ADR(1),               /* instruction mode */
81
+  0x008,                                /* display start low */
82
+  U8G_ESC_ADR(0),               /* data mode */
83
+  0x000,                                /*  */
84
+
85
+  U8G_ESC_ADR(1),               /* instruction mode */
86
+  0x009,                                /* display start high */
87
+  U8G_ESC_ADR(0),               /* data mode */
88
+  0x000,                                /*  */
89
+    
90
+  U8G_ESC_DLY(10),               /* delay 10 ms */
91
+  
92
+  U8G_ESC_CS(0),             /* disable chip */
93
+  U8G_ESC_END                /* end of sequence */
94
+};
95
+
96
+uint8_t u8g_dev_lc7981_160x80_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
97
+{
98
+  switch(msg)
99
+  {
100
+    case U8G_DEV_MSG_INIT:
101
+      u8g_InitCom(u8g, dev);
102
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_lc7981_160x80_init_seq);
103
+      break;
104
+    case U8G_DEV_MSG_STOP:
105
+      break;
106
+    case U8G_DEV_MSG_PAGE_NEXT:
107
+      {
108
+        uint8_t y, i;
109
+        uint16_t disp_ram_adr;
110
+        uint8_t *ptr;
111
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
112
+        
113
+        u8g_SetAddress(u8g, dev, 1);           /* cmd mode */
114
+        u8g_SetChipSelect(u8g, dev, 1);
115
+        y = pb->p.page_y0;
116
+        ptr = pb->buf;
117
+        disp_ram_adr = WIDTH/8;
118
+        disp_ram_adr *= y;
119
+        for( i = 0; i < 8; i ++ )
120
+        {
121
+          u8g_SetAddress(u8g, dev, 1);           /* cmd mode */
122
+          u8g_WriteByte(u8g, dev, 0x00a );      /* display ram (cursor) address low byte */
123
+          u8g_SetAddress(u8g, dev, 0);           /* data mode */
124
+          u8g_WriteByte(u8g, dev, disp_ram_adr & 0x0ff );  
125
+
126
+          u8g_SetAddress(u8g, dev, 1);           /* cmd mode */
127
+          u8g_WriteByte(u8g, dev, 0x00b );      /* display ram (cursor) address hight byte */
128
+          u8g_SetAddress(u8g, dev, 0);           /* data mode */
129
+          u8g_WriteByte(u8g, dev, disp_ram_adr >> 8 );  
130
+          
131
+          u8g_SetAddress(u8g, dev, 1);           /* cmd mode */
132
+          u8g_WriteByte(u8g, dev, 0x00c );      /* write data */
133
+          u8g_SetAddress(u8g, dev, 0);           /* data mode */
134
+          u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
135
+          ptr += WIDTH/8;
136
+          disp_ram_adr += WIDTH/8;
137
+        }
138
+        u8g_SetChipSelect(u8g, dev, 0);
139
+      }
140
+      break;
141
+  }
142
+  return u8g_dev_pb8h1f_base_fn(u8g, dev, msg, arg);
143
+}
144
+
145
+U8G_PB_DEV(u8g_dev_lc7981_160x80_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_lc7981_160x80_fn, U8G_COM_FAST_PARALLEL);
146
+
147
+

+ 145
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_lc7981_240x128.c View File

@@ -0,0 +1,145 @@
1
+/*
2
+
3
+  u8g_dev_lc7981_240x128.c
4
+  
5
+  Hitachi Display SP14N002
6
+  
7
+  Universal 8bit Graphics Library
8
+  
9
+  Copyright (c) 2012, olikraus@gmail.com
10
+  All rights reserved.
11
+
12
+  Redistribution and use in source and binary forms, with or without modification, 
13
+  are permitted provided that the following conditions are met:
14
+
15
+  * Redistributions of source code must retain the above copyright notice, this list 
16
+    of conditions and the following disclaimer.
17
+    
18
+  * Redistributions in binary form must reproduce the above copyright notice, this 
19
+    list of conditions and the following disclaimer in the documentation and/or other 
20
+    materials provided with the distribution.
21
+
22
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
23
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
24
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
25
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
26
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
27
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
28
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
29
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
30
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
31
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
32
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
33
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
34
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
35
+  
36
+  
37
+*/
38
+
39
+#include "u8g.h"
40
+
41
+#define WIDTH 240
42
+#define HEIGHT 128
43
+#define PAGE_HEIGHT 8
44
+
45
+
46
+/*
47
+  http://www.mark-products.com/graphics.htm#240x128%20Pixel%20Format
48
+*/
49
+
50
+static const uint8_t u8g_dev_lc7981_240x128_init_seq[] PROGMEM = {
51
+  U8G_ESC_CS(0),             /* disable chip */
52
+  U8G_ESC_ADR(1),           /* instruction mode */
53
+  U8G_ESC_RST(15),           /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
54
+  U8G_ESC_CS(1),             /* enable chip */
55
+  U8G_ESC_DLY(50),         /* delay 50 ms */
56
+  
57
+  
58
+  U8G_ESC_ADR(1),               /* instruction mode */
59
+  0x000,                                /* mode register */
60
+  U8G_ESC_ADR(0),               /* data mode */
61
+  0x032,                                /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1)*/
62
+
63
+  U8G_ESC_ADR(1),               /* instruction mode */
64
+  0x001,                                /* character/bits per pixel pitch */
65
+  U8G_ESC_ADR(0),               /* data mode */
66
+  0x007,                                /* 8 bits per pixel */
67
+
68
+  U8G_ESC_ADR(1),               /* instruction mode */
69
+  0x002,                                /* number of chars/byte width of the screen */
70
+  U8G_ESC_ADR(0),               /* data mode */
71
+  WIDTH/8-1,                         /* 8 bits per pixel */
72
+
73
+  U8G_ESC_ADR(1),               /* instruction mode */
74
+  0x003,                                /* time division */
75
+  U8G_ESC_ADR(0),               /* data mode */
76
+  0x07f,                                /*  */
77
+
78
+  U8G_ESC_ADR(1),               /* instruction mode */
79
+  0x008,                                /* display start low */
80
+  U8G_ESC_ADR(0),               /* data mode */
81
+  0x000,                                /*  */
82
+
83
+  U8G_ESC_ADR(1),               /* instruction mode */
84
+  0x009,                                /* display start high */
85
+  U8G_ESC_ADR(0),               /* data mode */
86
+  0x000,                                /*  */
87
+    
88
+  U8G_ESC_DLY(10),               /* delay 10 ms */
89
+  
90
+  U8G_ESC_CS(0),             /* disable chip */
91
+  U8G_ESC_END                /* end of sequence */
92
+};
93
+
94
+uint8_t u8g_dev_lc7981_240x128_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
95
+{
96
+  switch(msg)
97
+  {
98
+    case U8G_DEV_MSG_INIT:
99
+      u8g_InitCom(u8g, dev);
100
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_lc7981_240x128_init_seq);
101
+      break;
102
+    case U8G_DEV_MSG_STOP:
103
+      break;
104
+    case U8G_DEV_MSG_PAGE_NEXT:
105
+      {
106
+        uint8_t y, i;
107
+        uint16_t disp_ram_adr;
108
+        uint8_t *ptr;
109
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
110
+        
111
+        u8g_SetAddress(u8g, dev, 1);           /* cmd mode */
112
+        u8g_SetChipSelect(u8g, dev, 1);
113
+        y = pb->p.page_y0;
114
+        ptr = pb->buf;
115
+        disp_ram_adr = WIDTH/8;
116
+        disp_ram_adr *= y;
117
+        for( i = 0; i < 8; i ++ )
118
+        {
119
+          u8g_SetAddress(u8g, dev, 1);           /* cmd mode */
120
+          u8g_WriteByte(u8g, dev, 0x00a );      /* display ram (cursor) address low byte */
121
+          u8g_SetAddress(u8g, dev, 0);           /* data mode */
122
+          u8g_WriteByte(u8g, dev, disp_ram_adr & 0x0ff );  
123
+
124
+          u8g_SetAddress(u8g, dev, 1);           /* cmd mode */
125
+          u8g_WriteByte(u8g, dev, 0x00b );      /* display ram (cursor) address hight byte */
126
+          u8g_SetAddress(u8g, dev, 0);           /* data mode */
127
+          u8g_WriteByte(u8g, dev, disp_ram_adr >> 8 );  
128
+          
129
+          u8g_SetAddress(u8g, dev, 1);           /* cmd mode */
130
+          u8g_WriteByte(u8g, dev, 0x00c );      /* write data */
131
+          u8g_SetAddress(u8g, dev, 0);           /* data mode */
132
+          u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
133
+          ptr += WIDTH/8;
134
+          disp_ram_adr += WIDTH/8;
135
+        }
136
+        u8g_SetChipSelect(u8g, dev, 0);
137
+      }
138
+      break;
139
+  }
140
+  return u8g_dev_pb8h1f_base_fn(u8g, dev, msg, arg);
141
+}
142
+
143
+U8G_PB_DEV(u8g_dev_lc7981_240x128_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_lc7981_240x128_fn, U8G_COM_FAST_PARALLEL);
144
+
145
+

+ 145
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_lc7981_240x64.c View File

@@ -0,0 +1,145 @@
1
+/*
2
+
3
+  u8g_dev_lc7981_240x64.c
4
+  
5
+  Tested with Nan Ya LM_J6_003_
6
+  
7
+  Universal 8bit Graphics Library
8
+  
9
+  Copyright (c) 2012, olikraus@gmail.com
10
+  All rights reserved.
11
+
12
+  Redistribution and use in source and binary forms, with or without modification, 
13
+  are permitted provided that the following conditions are met:
14
+
15
+  * Redistributions of source code must retain the above copyright notice, this list 
16
+    of conditions and the following disclaimer.
17
+    
18
+  * Redistributions in binary form must reproduce the above copyright notice, this 
19
+    list of conditions and the following disclaimer in the documentation and/or other 
20
+    materials provided with the distribution.
21
+
22
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
23
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
24
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
25
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
26
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
27
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
28
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
29
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
30
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
31
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
32
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
33
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
34
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
35
+  
36
+  
37
+*/
38
+
39
+#include "u8g.h"
40
+
41
+#define WIDTH 240
42
+#define HEIGHT 64
43
+#define PAGE_HEIGHT 8
44
+
45
+
46
+/*
47
+  http://www.mark-products.com/graphics.htm#240x64%20Pixel%20Format
48
+*/
49
+
50
+static const uint8_t u8g_dev_lc7981_240x64_init_seq[] PROGMEM = {
51
+  U8G_ESC_CS(0),             /* disable chip */
52
+  U8G_ESC_ADR(1),           /* instruction mode */
53
+  U8G_ESC_RST(15),           /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
54
+  U8G_ESC_CS(1),             /* enable chip */
55
+  U8G_ESC_DLY(50),         /* delay 50 ms */
56
+  
57
+  
58
+  U8G_ESC_ADR(1),               /* instruction mode */
59
+  0x000,                                /* mode register */
60
+  U8G_ESC_ADR(0),               /* data mode */
61
+  0x032,                                /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1)*/
62
+
63
+  U8G_ESC_ADR(1),               /* instruction mode */
64
+  0x001,                                /* character/bits per pixel pitch */
65
+  U8G_ESC_ADR(0),               /* data mode */
66
+  0x007,                                /* 8 bits per pixel */
67
+
68
+  U8G_ESC_ADR(1),               /* instruction mode */
69
+  0x002,                                /* number of chars/byte width of the screen */
70
+  U8G_ESC_ADR(0),               /* data mode */
71
+  WIDTH/8-1,                         /* 8 bits per pixel */
72
+
73
+  U8G_ESC_ADR(1),               /* instruction mode */
74
+  0x003,                                /* time division */
75
+  U8G_ESC_ADR(0),               /* data mode */
76
+  0x07f,                                /*  */
77
+
78
+  U8G_ESC_ADR(1),               /* instruction mode */
79
+  0x008,                                /* display start low */
80
+  U8G_ESC_ADR(0),               /* data mode */
81
+  0x000,                                /*  */
82
+
83
+  U8G_ESC_ADR(1),               /* instruction mode */
84
+  0x009,                                /* display start high */
85
+  U8G_ESC_ADR(0),               /* data mode */
86
+  0x000,                                /*  */
87
+    
88
+  U8G_ESC_DLY(10),               /* delay 10 ms */
89
+  
90
+  U8G_ESC_CS(0),             /* disable chip */
91
+  U8G_ESC_END                /* end of sequence */
92
+};
93
+
94
+uint8_t u8g_dev_lc7981_240x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
95
+{
96
+  switch(msg)
97
+  {
98
+    case U8G_DEV_MSG_INIT:
99
+      u8g_InitCom(u8g, dev);
100
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_lc7981_240x64_init_seq);
101
+      break;
102
+    case U8G_DEV_MSG_STOP:
103
+      break;
104
+    case U8G_DEV_MSG_PAGE_NEXT:
105
+      {
106
+        uint8_t y, i;
107
+        uint16_t disp_ram_adr;
108
+        uint8_t *ptr;
109
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
110
+        
111
+        u8g_SetAddress(u8g, dev, 1);           /* cmd mode */
112
+        u8g_SetChipSelect(u8g, dev, 1);
113
+        y = pb->p.page_y0;
114
+        ptr = pb->buf;
115
+        disp_ram_adr = WIDTH/8;
116
+        disp_ram_adr *= y;
117
+        for( i = 0; i < 8; i ++ )
118
+        {
119
+          u8g_SetAddress(u8g, dev, 1);           /* cmd mode */
120
+          u8g_WriteByte(u8g, dev, 0x00a );      /* display ram (cursor) address low byte */
121
+          u8g_SetAddress(u8g, dev, 0);           /* data mode */
122
+          u8g_WriteByte(u8g, dev, disp_ram_adr & 0x0ff );  
123
+
124
+          u8g_SetAddress(u8g, dev, 1);           /* cmd mode */
125
+          u8g_WriteByte(u8g, dev, 0x00b );      /* display ram (cursor) address hight byte */
126
+          u8g_SetAddress(u8g, dev, 0);           /* data mode */
127
+          u8g_WriteByte(u8g, dev, disp_ram_adr >> 8 );  
128
+          
129
+          u8g_SetAddress(u8g, dev, 1);           /* cmd mode */
130
+          u8g_WriteByte(u8g, dev, 0x00c );      /* write data */
131
+          u8g_SetAddress(u8g, dev, 0);           /* data mode */
132
+          u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
133
+          ptr += WIDTH/8;
134
+          disp_ram_adr += WIDTH/8;
135
+        }
136
+        u8g_SetChipSelect(u8g, dev, 0);
137
+      }
138
+      break;
139
+  }
140
+  return u8g_dev_pb8h1f_base_fn(u8g, dev, msg, arg);
141
+}
142
+
143
+U8G_PB_DEV(u8g_dev_lc7981_240x64_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_lc7981_240x64_fn, U8G_COM_FAST_PARALLEL);
144
+
145
+

+ 145
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_lc7981_320x64.c View File

@@ -0,0 +1,145 @@
1
+/*
2
+
3
+  u8g_dev_lc7981_320x64.c
4
+
5
+  Note: Requires 16 bit mode (Must be enabled in u8g.h)
6
+  
7
+  Tested with Varitronix MGLS32064-03.pdf
8
+  
9
+  Universal 8bit Graphics Library
10
+  
11
+  Copyright (c) 2012, olikraus@gmail.com
12
+  All rights reserved.
13
+
14
+  Redistribution and use in source and binary forms, with or without modification, 
15
+  are permitted provided that the following conditions are met:
16
+
17
+  * Redistributions of source code must retain the above copyright notice, this list 
18
+    of conditions and the following disclaimer.
19
+    
20
+  * Redistributions in binary form must reproduce the above copyright notice, this 
21
+    list of conditions and the following disclaimer in the documentation and/or other 
22
+    materials provided with the distribution.
23
+
24
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
25
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
26
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
27
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
28
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
29
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
30
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
31
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
32
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
33
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
34
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
35
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
36
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
37
+  
38
+  
39
+*/
40
+
41
+#include "u8g.h"
42
+
43
+#define WIDTH 320
44
+#define HEIGHT 64
45
+#define PAGE_HEIGHT 8
46
+
47
+
48
+/*
49
+  http://www.gaw.ru/pdf/lcd/lcm/Varitronix/graf/MGLS32064-03.pdf
50
+*/
51
+
52
+static const uint8_t u8g_dev_lc7981_320x64_init_seq[] PROGMEM = {
53
+  U8G_ESC_CS(0),             /* disable chip */
54
+  U8G_ESC_ADR(1),           /* instruction mode */
55
+  U8G_ESC_RST(15),           /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
56
+  U8G_ESC_CS(1),             /* enable chip */
57
+  U8G_ESC_DLY(50),         /* delay 50 ms */
58
+  
59
+  
60
+  U8G_ESC_ADR(1),               /* instruction mode */
61
+  0x000,                                /* mode register */
62
+  U8G_ESC_ADR(0),               /* data mode */
63
+  0x032,                                /* display on (bit 5), master mode on (bit 4), graphics mode on (bit 1)*/
64
+
65
+  U8G_ESC_ADR(1),               /* instruction mode */
66
+  0x001,                                /* character/bits per pixel pitch */
67
+  U8G_ESC_ADR(0),               /* data mode */
68
+  0x007,                                /* 8 bits per pixel */
69
+
70
+  U8G_ESC_ADR(1),               /* instruction mode */
71
+  0x002,                                /* number of chars/byte width of the screen */
72
+  U8G_ESC_ADR(0),               /* data mode */
73
+  WIDTH/8-1,                         /* 8 bits per pixel */
74
+
75
+  U8G_ESC_ADR(1),               /* instruction mode */
76
+  0x003,                                /* time division */
77
+  U8G_ESC_ADR(0),               /* data mode */
78
+  0x07f,                                /*  */
79
+
80
+  U8G_ESC_ADR(1),               /* instruction mode */
81
+  0x008,                                /* display start low */
82
+  U8G_ESC_ADR(0),               /* data mode */
83
+  0x000,                                /*  */
84
+
85
+  U8G_ESC_ADR(1),               /* instruction mode */
86
+  0x009,                                /* display start high */
87
+  U8G_ESC_ADR(0),               /* data mode */
88
+  0x000,                                /*  */
89
+    
90
+  U8G_ESC_DLY(10),               /* delay 10 ms */
91
+  
92
+  U8G_ESC_CS(0),             /* disable chip */
93
+  U8G_ESC_END                /* end of sequence */
94
+};
95
+
96
+uint8_t u8g_dev_lc7981_320x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
97
+{
98
+  switch(msg)
99
+  {
100
+    case U8G_DEV_MSG_INIT:
101
+      u8g_InitCom(u8g, dev);
102
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_lc7981_320x64_init_seq);
103
+      break;
104
+    case U8G_DEV_MSG_STOP:
105
+      break;
106
+    case U8G_DEV_MSG_PAGE_NEXT:
107
+      {
108
+        uint8_t y, i;
109
+        uint16_t disp_ram_adr;
110
+        uint8_t *ptr;
111
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
112
+        
113
+        u8g_SetAddress(u8g, dev, 1);           /* cmd mode */
114
+        u8g_SetChipSelect(u8g, dev, 1);
115
+        y = pb->p.page_y0;
116
+        ptr = pb->buf;
117
+        disp_ram_adr = WIDTH/8;
118
+        disp_ram_adr *= y;
119
+        for( i = 0; i < 8; i ++ )
120
+        {
121
+          u8g_SetAddress(u8g, dev, 1);           /* cmd mode */
122
+          u8g_WriteByte(u8g, dev, 0x00a );      /* display ram (cursor) address low byte */
123
+          u8g_SetAddress(u8g, dev, 0);           /* data mode */
124
+          u8g_WriteByte(u8g, dev, disp_ram_adr & 0x0ff );  
125
+
126
+          u8g_SetAddress(u8g, dev, 1);           /* cmd mode */
127
+          u8g_WriteByte(u8g, dev, 0x00b );      /* display ram (cursor) address hight byte */
128
+          u8g_SetAddress(u8g, dev, 0);           /* data mode */
129
+          u8g_WriteByte(u8g, dev, disp_ram_adr >> 8 );  
130
+          
131
+          u8g_SetAddress(u8g, dev, 1);           /* cmd mode */
132
+          u8g_WriteByte(u8g, dev, 0x00c );      /* write data */
133
+          u8g_SetAddress(u8g, dev, 0);           /* data mode */
134
+          u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
135
+          ptr += WIDTH/8;
136
+          disp_ram_adr += WIDTH/8;
137
+        }
138
+        u8g_SetChipSelect(u8g, dev, 0);
139
+      }
140
+      break;
141
+  }
142
+  return u8g_dev_pb8h1f_base_fn(u8g, dev, msg, arg);
143
+}
144
+
145
+U8G_PB_DEV(u8g_dev_lc7981_320x64_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_lc7981_320x64_fn, U8G_COM_FAST_PARALLEL);

+ 67
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_null.c View File

@@ -0,0 +1,67 @@
1
+/*
2
+
3
+  u8g_dev_null.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+  
35
+*/
36
+
37
+#include "u8g.h"
38
+
39
+uint8_t u8g_dev_null(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
40
+{
41
+  switch(msg)
42
+  {
43
+    case U8G_DEV_MSG_SET_8PIXEL:                /* most often used command */
44
+      break;
45
+    case U8G_DEV_MSG_SET_PIXEL:
46
+      break;
47
+    case U8G_DEV_MSG_INIT:
48
+      break;
49
+    case U8G_DEV_MSG_STOP:
50
+      break;
51
+    case U8G_DEV_MSG_PAGE_FIRST:
52
+      break;
53
+    case U8G_DEV_MSG_PAGE_NEXT:
54
+      break;
55
+#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
56
+    case U8G_DEV_MSG_IS_BBX_INTERSECTION:
57
+      return 1;
58
+#endif
59
+    case U8G_DEV_MSG_GET_PAGE_BOX:
60
+      break;
61
+    case U8G_DEV_MSG_SET_COLOR_INDEX:
62
+      break;
63
+    case U8G_DEV_MSG_SET_XY_CB:
64
+      break;
65
+  }
66
+  return 1;
67
+}

+ 110
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_pcd8544_84x48.c View File

@@ -0,0 +1,110 @@
1
+/*
2
+
3
+  u8g_dev_pcd8544_84x48.c
4
+  
5
+  Display: Nokia 84x48
6
+  
7
+  Status: Tested with PCF8812 Display
8
+  
9
+
10
+  Universal 8bit Graphics Library
11
+  
12
+  Copyright (c) 2011, olikraus@gmail.com
13
+  All rights reserved.
14
+
15
+  Redistribution and use in source and binary forms, with or without modification, 
16
+  are permitted provided that the following conditions are met:
17
+
18
+  * Redistributions of source code must retain the above copyright notice, this list 
19
+    of conditions and the following disclaimer.
20
+    
21
+  * Redistributions in binary form must reproduce the above copyright notice, this 
22
+    list of conditions and the following disclaimer in the documentation and/or other 
23
+    materials provided with the distribution.
24
+
25
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
26
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
27
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
28
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
29
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
30
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
31
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
32
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
33
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
34
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
35
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
36
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
37
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
38
+  
39
+  
40
+*/
41
+
42
+#include "u8g.h"
43
+
44
+#define WIDTH 84
45
+#define HEIGHT 48
46
+#define PAGE_HEIGHT 8
47
+
48
+
49
+static const uint8_t u8g_dev_pcd8544_init_seq[] PROGMEM = {
50
+  U8G_ESC_CS(0),             /* disable chip */
51
+  U8G_ESC_ADR(0),           /* instruction mode */
52
+  U8G_ESC_RST(1),           /* do reset low pulse with (1*16)+2 milliseconds */
53
+  U8G_ESC_CS(1),             /* enable chip */
54
+  0x021,		/* activate chip (PD=0), horizontal increment (V=0), enter extended command set (H=1) */
55
+  0x006,		/* temp. control: b10 = 2 */
56
+  0x013,		/* bias system 1:48 */
57
+  0x0c0,		/* medium Vop */
58
+  0x020,		/* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
59
+  0x00c,		/* display on, normal operation */
60
+  U8G_ESC_DLY(100),       /* delay 100 ms */
61
+  0x020,		                /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
62
+  0x00d,		                /* display on, invert */
63
+  U8G_ESC_DLY(100),       /* delay 100 ms */
64
+  U8G_ESC_DLY(100),       /* delay 100 ms */
65
+  0x020,		                /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
66
+  0x00c,		                /* display on, normal */
67
+  U8G_ESC_DLY(100),       /* delay 100 ms */
68
+  U8G_ESC_CS(0),             /* disable chip */
69
+  U8G_ESC_END                /* end of sequence */
70
+};
71
+
72
+uint8_t u8g_dev_pcd8544_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
73
+{
74
+  switch(msg)
75
+  {
76
+    case U8G_DEV_MSG_INIT:
77
+      u8g_InitCom(u8g, dev);
78
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_pcd8544_init_seq);
79
+      break;
80
+    case U8G_DEV_MSG_STOP:
81
+      break;
82
+    case U8G_DEV_MSG_PAGE_NEXT:
83
+      {
84
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
85
+        u8g_SetAddress(u8g, dev, 0);           /* command mode */
86
+        u8g_SetChipSelect(u8g, dev, 1);
87
+        u8g_WriteByte(u8g, dev, 0x020 );		/* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
88
+        u8g_WriteByte(u8g, dev, 0x080 );                        /* set X address */
89
+        u8g_WriteByte(u8g, dev, 0x040 | pb->p.page); /* set Y address */
90
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
91
+        if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
92
+          return 0;
93
+        u8g_SetChipSelect(u8g, dev, 0);
94
+      }
95
+      break;
96
+    case U8G_DEV_MSG_CONTRAST:
97
+      /* the contrast adjustment does not work, needs to be analysed */
98
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
99
+      u8g_SetChipSelect(u8g, dev, 1);
100
+      u8g_WriteByte(u8g, dev, 0x021);        /* command mode, extended function set */
101
+      u8g_WriteByte(u8g, dev, 0x080 | ( (*(uint8_t *)arg) >> 1 ) );
102
+      u8g_SetChipSelect(u8g, dev, 0);
103
+      return 1;
104
+  }
105
+  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
106
+}
107
+
108
+
109
+U8G_PB_DEV(u8g_dev_pcd8544_84x48_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_pcd8544_fn, U8G_COM_SW_SPI);
110
+

+ 123
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_pcf8812_96x65.c View File

@@ -0,0 +1,123 @@
1
+/*
2
+
3
+  u8g_dev_pcf8812_96x65.c
4
+  
5
+  Display: Nokia 96x65
6
+
7
+  Universal 8bit Graphics Library
8
+  
9
+  Copyright (c) 2011, olikraus@gmail.com
10
+  All rights reserved.
11
+
12
+  Redistribution and use in source and binary forms, with or without modification, 
13
+  are permitted provided that the following conditions are met:
14
+
15
+  * Redistributions of source code must retain the above copyright notice, this list 
16
+    of conditions and the following disclaimer.
17
+    
18
+  * Redistributions in binary form must reproduce the above copyright notice, this 
19
+    list of conditions and the following disclaimer in the documentation and/or other 
20
+    materials provided with the distribution.
21
+
22
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
23
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
24
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
25
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
26
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
27
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
28
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
29
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
30
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
31
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
32
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
33
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
34
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
35
+  
36
+
37
+  
38
+  om6206        comaptible to pcf8812 ?
39
+  
40
+  Status: Tested 
41
+
42
+
43
+  Display                                               Controller              Seen in
44
+  LPH7366 (9 pins, 84x48)                       PCD8544                Nokia 5110 / 5120 / 5130 / 5160 / 6110 / 6150 
45
+  LPH7677 (8 pins, 84x48)                       PCD8544                         Nokia 3210
46
+  LPH7779 (8 pins, 84x48)                       PCD8544                         Nokia 3310 / 3315 / 3330 / 3110, also 3410?
47
+  ???                                                          PCD8544                          Nokia 5110 / 6110
48
+  LPH7690 ?  (96x65)                                 PCF8455/OM6202          Nokia 3410
49
+  LPH7690 ? (96x65?)                               SED1565/S1D15605        Nokia 7110 / 3510?
50
+  LPH7690                                                     ???                                     Nokia 6210
51
+
52
+
53
+  
54
+*/
55
+
56
+#include "u8g.h"
57
+
58
+#define WIDTH 96
59
+#define HEIGHT 65
60
+#define PAGE_HEIGHT 8
61
+
62
+
63
+static const uint8_t u8g_dev_pcf8812_init_seq[] PROGMEM = {
64
+  U8G_ESC_CS(0),             /* disable chip */
65
+  U8G_ESC_ADR(0),           /* instruction mode */
66
+  U8G_ESC_RST(1),           /* do reset low pulse with (1*16)+2 milliseconds */
67
+  U8G_ESC_CS(1),             /* enable chip */
68
+  0x021,		                /* activate chip (PD=0), horizontal increment (V=0), enter extended command set (H=1) */
69
+  0x006,		                /* temp. control: b10 = 2 */
70
+  0x013,		                /* bias system 1:48 */
71
+  0x080 | 0x040,		/* medium Vop */
72
+  0x020,		                /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
73
+  0x00c,		                /* display on, normal operation */
74
+  U8G_ESC_DLY(100),       /* delay 100 ms */
75
+  0x020,		                /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
76
+  0x00d,		                /* display on, invert */
77
+  U8G_ESC_DLY(100),       /* delay 100 ms */
78
+  U8G_ESC_DLY(100),       /* delay 100 ms */
79
+  0x020,		                /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
80
+  0x00c,		                /* display on, normal */
81
+  U8G_ESC_DLY(100),       /* delay 100 ms */
82
+  U8G_ESC_CS(0),             /* disable chip */
83
+  U8G_ESC_END                /* end of sequence */
84
+};
85
+
86
+uint8_t u8g_dev_pcf8812_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
87
+{
88
+  switch(msg)
89
+  {
90
+    case U8G_DEV_MSG_INIT:
91
+      u8g_InitCom(u8g, dev);
92
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_pcf8812_init_seq);
93
+      break;
94
+    case U8G_DEV_MSG_STOP:
95
+      break;
96
+    case U8G_DEV_MSG_PAGE_NEXT:
97
+      {
98
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
99
+        u8g_SetAddress(u8g, dev, 0);           /* command mode */
100
+        u8g_SetChipSelect(u8g, dev, 1);
101
+        u8g_WriteByte(u8g, dev, 0x020 );		/* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
102
+        u8g_WriteByte(u8g, dev, 0x080 );                        /* set X address */
103
+        u8g_WriteByte(u8g, dev, 0x040 | pb->p.page); /* set Y address */
104
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
105
+        if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
106
+          return 0;
107
+        u8g_SetChipSelect(u8g, dev, 0);
108
+      }
109
+      break;
110
+    case U8G_DEV_MSG_CONTRAST:
111
+      /* the contrast adjustment does not work, needs to be analysed */
112
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
113
+      u8g_SetChipSelect(u8g, dev, 1);
114
+      u8g_WriteByte(u8g, dev, 0x021);        /* command mode, extended function set */
115
+      u8g_WriteByte(u8g, dev, 0x080 | ( (*(uint8_t *)arg) >> 1 ) );
116
+      u8g_SetChipSelect(u8g, dev, 0);
117
+      return 1;
118
+  }
119
+  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
120
+}
121
+
122
+/* u8g_com_arduino_sw_spi_fn does not work, too fast??? */
123
+U8G_PB_DEV(u8g_dev_pcf8812_96x65_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_pcf8812_fn, U8G_COM_SW_SPI);

+ 107
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_sbn1661_122x32.c View File

@@ -0,0 +1,107 @@
1
+/*
2
+
3
+  u8g_dev_sbn1661_122x32.c
4
+  
5
+  WG12232 display with 2xSBN1661 / SED1520 controller (122x32 display)
6
+  At the moment only available in the Arduino Environment
7
+
8
+  Universal 8bit Graphics Library
9
+  
10
+  Copyright (c) 2011, olikraus@gmail.com
11
+  All rights reserved.
12
+
13
+  Redistribution and use in source and binary forms, with or without modification, 
14
+  are permitted provided that the following conditions are met:
15
+
16
+  * Redistributions of source code must retain the above copyright notice, this list 
17
+    of conditions and the following disclaimer.
18
+    
19
+  * Redistributions in binary form must reproduce the above copyright notice, this 
20
+    list of conditions and the following disclaimer in the documentation and/or other 
21
+    materials provided with the distribution.
22
+
23
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
24
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
25
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
26
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
27
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
28
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
29
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
30
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
31
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
32
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
33
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
34
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
35
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
36
+  
37
+  
38
+*/
39
+
40
+#include "u8g.h"
41
+
42
+#define WIDTH 122
43
+#define HEIGHT 32
44
+#define PAGE_HEIGHT 8
45
+
46
+
47
+static const uint8_t u8g_dev_sbn1661_122x32_init_seq[] PROGMEM = {
48
+  U8G_ESC_CS(0),             /* disable chip */
49
+  U8G_ESC_ADR(0),           /* instruction mode */
50
+  U8G_ESC_RST(15),           /* do reset low pulse with (15*16)+2 milliseconds */
51
+  U8G_ESC_CS(1),             /* enable chip 1 */
52
+  0x0af,				/* display on */
53
+  0x0c0,				/* display start at line 0 */
54
+  0x0a0,				/* a0: ADC forward, a1: ADC reverse */
55
+  0x0a9,				/* a8: 1/16, a9: 1/32 duty */
56
+  U8G_ESC_CS(2),             /* enable chip 2 */
57
+  0x0af,				/* display on */
58
+  0x0c0,				/* display start at line 0 */
59
+  0x0a0,				/* a0: ADC forward, a1: ADC reverse */
60
+  0x0a9,				/* a8: 1/16, a9: 1/32 duty */
61
+  
62
+  U8G_ESC_CS(0),             /* disable chip */
63
+  
64
+  
65
+  U8G_ESC_END                /* end of sequence */
66
+};
67
+
68
+uint8_t u8g_dev_sbn1661_122x32_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
69
+{
70
+  switch(msg)
71
+  {
72
+    case U8G_DEV_MSG_INIT:
73
+      u8g_InitCom(u8g, dev);
74
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_sbn1661_122x32_init_seq);
75
+      break;
76
+    case U8G_DEV_MSG_STOP:
77
+      break;
78
+    case U8G_DEV_MSG_PAGE_NEXT:
79
+      {
80
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
81
+	
82
+        u8g_SetAddress(u8g, dev, 0);           /* command mode */
83
+        u8g_SetChipSelect(u8g, dev, 1);
84
+        u8g_WriteByte(u8g, dev, 0x0b8 | pb->p.page); /* select current page (SBN1661/SED1520) */
85
+        u8g_WriteByte(u8g, dev, 0x000 ); /* set X address */
86
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
87
+        u8g_WriteSequence(u8g, dev, WIDTH/2, pb->buf);
88
+	
89
+        u8g_SetAddress(u8g, dev, 0);           /* command mode */
90
+        u8g_SetChipSelect(u8g, dev, 2);
91
+        u8g_WriteByte(u8g, dev, 0x0b8 | pb->p.page); /* select current page (SBN1661/SED1520) */
92
+        u8g_WriteByte(u8g, dev, 0x000 ); /* set X address */
93
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
94
+        u8g_WriteSequence(u8g, dev, WIDTH/2, WIDTH/2+(uint8_t *)pb->buf);
95
+	
96
+        u8g_SetChipSelect(u8g, dev, 0);
97
+	
98
+      }
99
+      break;
100
+    case U8G_DEV_MSG_CONTRAST:
101
+      break;
102
+  }
103
+  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
104
+}
105
+
106
+/* u8g_com_arduino_sw_spi_fn does not work, too fast??? */
107
+U8G_PB_DEV(u8g_dev_sbn1661_122x32 , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_sbn1661_122x32_fn, u8g_com_arduino_no_en_parallel_fn);

+ 247
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1306_128x32.c View File

@@ -0,0 +1,247 @@
1
+/*
2
+
3
+  u8g_dev_ssd1306_128x32.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+
34
+  
35
+  23 Feb 2013: Fixed, Issue 147
36
+
37
+*/
38
+
39
+
40
+#include "u8g.h"
41
+
42
+#define WIDTH 128
43
+#define HEIGHT 32
44
+#define PAGE_HEIGHT 8
45
+
46
+
47
+/* init sequence adafruit 128x32 OLED (NOT TESTED) */
48
+static const uint8_t u8g_dev_ssd1306_128x32_adafruit1_init_seq[] PROGMEM = {
49
+  U8G_ESC_CS(0),        /* disable chip */
50
+  U8G_ESC_ADR(0),       /* instruction mode */
51
+  U8G_ESC_RST(1),       /* do reset low pulse with (1*16)+2 milliseconds */
52
+  U8G_ESC_CS(1),        /* enable chip */
53
+
54
+  0x0ae,				/* display off, sleep mode */
55
+  0x0d5, 0x080,			/* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
56
+  0x0a8, 0x03f,			/* */
57
+
58
+  0x0d3, 0x000,			/*  */
59
+
60
+  0x040,				/* start line */
61
+  
62
+  0x08d, 0x010,			/* [1] charge pump setting (p62): 0x014 enable, 0x010 disable */
63
+
64
+  0x020, 0x000,			/* */
65
+  0x0a1,				/* segment remap a0/a1*/
66
+  0x0c8,				/* c0: scan dir normal, c8: reverse */
67
+  0x0da, 0x012,			/* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
68
+  0x081, 0x09f,			/* [1] set contrast control */
69
+  0x0d9, 0x022,			/* [1] pre-charge period 0x022/f1*/
70
+  0x0db, 0x040,			/* vcomh deselect level */
71
+  
72
+  0x02e,				/* 2012-05-27: Deactivate scroll */ 
73
+  0x0a4,				/* output ram to display */
74
+  0x0a6,				/* none inverted normal display mode */
75
+  0x0af,				/* display on */
76
+
77
+  U8G_ESC_CS(0),        /* disable chip */
78
+  U8G_ESC_END           /* end of sequence */
79
+};
80
+
81
+
82
+/* init sequence adafruit 128x32 OLED (NOT TESTED) */
83
+static const uint8_t u8g_dev_ssd1306_128x32_adafruit2_init_seq[] PROGMEM = {
84
+  U8G_ESC_CS(0),        /* disable chip */
85
+  U8G_ESC_ADR(0),       /* instruction mode */
86
+  U8G_ESC_RST(1),       /* do reset low pulse with (1*16)+2 milliseconds */
87
+  U8G_ESC_CS(1),        /* enable chip */
88
+
89
+  0x0ae,				/* display off, sleep mode */
90
+  0x0d5, 0x080,			/* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
91
+  0x0a8, 0x03f,			/* */
92
+
93
+  0x0d3, 0x000,			/*  */
94
+
95
+  0x040,				/* start line */
96
+  
97
+  0x08d, 0x014,			/* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */
98
+
99
+  0x020, 0x000,			/* */
100
+  0x0a1,				/* segment remap a0/a1*/
101
+  0x0c8,				/* c0: scan dir normal, c8: reverse */
102
+  0x0da, 0x012,			/* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
103
+  0x081, 0x0cf,			/* [2] set contrast control */
104
+  0x0d9, 0x0f1,			/* [2] pre-charge period 0x022/f1*/
105
+  0x0db, 0x040,			/* vcomh deselect level */
106
+  
107
+  0x02e,				/* 2012-05-27: Deactivate scroll */ 
108
+  0x0a4,				/* output ram to display */
109
+  0x0a6,				/* none inverted normal display mode */
110
+  0x0af,				/* display on */
111
+
112
+  U8G_ESC_CS(0),        /* disable chip */
113
+  U8G_ESC_END           /* end of sequence */
114
+};
115
+
116
+
117
+/* init sequence adafruit 128x32 OLED (TESTED - WORKING 23.02.13), like adafruit3, but with page addressing mode */
118
+static const uint8_t u8g_dev_ssd1306_128x32_adafruit3_init_seq[] PROGMEM = {
119
+  U8G_ESC_CS(0),        /* disable chip */
120
+  U8G_ESC_ADR(0),       /* instruction mode */
121
+  U8G_ESC_RST(1),		/* do reset low pulse with (1*16)+2 milliseconds */
122
+  U8G_ESC_CS(1),        /* enable chip */
123
+
124
+  0x0ae,				/* display off, sleep mode */
125
+  0x0d5, 0x080,			/* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
126
+  0x0a8, 0x01f,			/* Feb 23, 2013: 128x32 OLED: 0x01f,  128x64 OLED 0x03f */
127
+
128
+  0x0d3, 0x000,			/*  */
129
+
130
+  0x040,				/* start line */
131
+  
132
+  0x08d, 0x014,			/* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */ 
133
+
134
+  0x020, 0x002,			/* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5), Feb 23, 2013: 128x32 OLED: 0x002,  128x64 OLED 0x012 */
135
+  0x0a1,				/* segment remap a0/a1*/
136
+  0x0c8,				/* c0: scan dir normal, c8: reverse */
137
+  0x0da, 0x002,			/* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
138
+  0x081, 0x0cf,			/* [2] set contrast control */
139
+  0x0d9, 0x0f1,			/* [2] pre-charge period 0x022/f1*/
140
+  0x0db, 0x040,			/* vcomh deselect level */
141
+  
142
+  0x02e,				/* 2012-05-27: Deactivate scroll */ 
143
+  0x0a4,				/* output ram to display */
144
+  0x0a6,				/* none inverted normal display mode */
145
+  0x0af,				/* display on */
146
+
147
+  U8G_ESC_CS(0),        /* disable chip */
148
+  U8G_ESC_END           /* end of sequence */
149
+};
150
+
151
+
152
+/* init sequence Univision datasheet (NOT TESTED) */
153
+static const uint8_t u8g_dev_ssd1306_128x32_univision_init_seq[] PROGMEM = {
154
+  U8G_ESC_CS(0),        /* disable chip */
155
+  U8G_ESC_ADR(0),       /* instruction mode */
156
+  U8G_ESC_RST(1),       /* do reset low pulse with (1*16)+2 milliseconds */
157
+  U8G_ESC_CS(1),        /* enable chip */
158
+
159
+  0x0ae,				/* display off, sleep mode */
160
+  0x0d5, 0x080,			/* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
161
+  0x0a8, 0x03f,			/* multiplex ratio */
162
+  0x0d3, 0x000,			/* display offset */
163
+  0x040,				/* start line */
164
+  0x08d, 0x010,			/* charge pump setting (p62): 0x014 enable, 0x010 disable */
165
+  0x0a1,				/* segment remap a0/a1*/
166
+  0x0c8,				/* c0: scan dir normal, c8: reverse */
167
+  0x0da, 0x012,			/* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
168
+  0x081, 0x09f,			/* set contrast control */
169
+  0x0d9, 0x022,			/* pre-charge period */
170
+  0x0db, 0x040,			/* vcomh deselect level */
171
+  0x022, 0x000,			/* page addressing mode WRONG: 3 byte cmd! */
172
+  0x0a4,				/* output ram to display */
173
+  0x0a6,				/* none inverted normal display mode */
174
+  0x0af,				/* display on */
175
+  U8G_ESC_CS(0),        /* disable chip */
176
+  U8G_ESC_END           /* end of sequence */
177
+};
178
+
179
+
180
+/* select one init sequence here */
181
+//define u8g_dev_ssd1306_128x32_init_seq u8g_dev_ssd1306_128x32_univision_init_seq
182
+//define u8g_dev_ssd1306_128x32_init_seq u8g_dev_ssd1306_128x32_adafruit1_init_seq
183
+//define u8g_dev_ssd1306_128x32_init_seq u8g_dev_ssd1306_128x32_adafruit2_init_seq
184
+#define u8g_dev_ssd1306_128x32_init_seq u8g_dev_ssd1306_128x32_adafruit3_init_seq
185
+
186
+
187
+static const uint8_t u8g_dev_ssd1306_128x32_data_start[] PROGMEM = {
188
+  U8G_ESC_ADR(0),       /* instruction mode */
189
+  U8G_ESC_CS(1),        /* enable chip */
190
+  0x010,				/* set upper 4 bit of the col adr. to 0 */
191
+  0x000,				/* set lower 4 bit of the col adr. to 4  */
192
+  U8G_ESC_END           /* end of sequence */
193
+};
194
+
195
+static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = {
196
+  U8G_ESC_ADR(0),           /* instruction mode */
197
+  U8G_ESC_CS(1),             /* enable chip */
198
+  0x0ae,		/* display off */      
199
+  U8G_ESC_CS(1),             /* disable chip */
200
+  U8G_ESC_END                /* end of sequence */
201
+};
202
+
203
+static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
204
+  U8G_ESC_ADR(0),           /* instruction mode */
205
+  U8G_ESC_CS(1),             /* enable chip */
206
+  0x0af,		/* display on */      
207
+  U8G_ESC_DLY(50),       /* delay 50 ms */
208
+  U8G_ESC_CS(1),             /* disable chip */
209
+  U8G_ESC_END                /* end of sequence */
210
+};
211
+
212
+uint8_t u8g_dev_ssd1306_128x32_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
213
+{
214
+  switch(msg)
215
+  {
216
+    case U8G_DEV_MSG_INIT:
217
+      u8g_InitCom(u8g, dev);
218
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x32_init_seq);
219
+      break;
220
+    case U8G_DEV_MSG_STOP:
221
+      break;
222
+    case U8G_DEV_MSG_PAGE_NEXT:
223
+      {
224
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
225
+        u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x32_data_start);    
226
+        u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page);	/* select current page (SSD1306) */
227
+        u8g_SetAddress(u8g, dev, 1);					/* data mode */
228
+        if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
229
+          return 0;
230
+        u8g_SetChipSelect(u8g, dev, 0);
231
+      }
232
+      break;
233
+    case U8G_DEV_MSG_SLEEP_ON:
234
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);    
235
+      return 1;
236
+    case U8G_DEV_MSG_SLEEP_OFF:
237
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);    
238
+      return 1;
239
+}
240
+  
241
+  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
242
+}
243
+
244
+U8G_PB_DEV(u8g_dev_ssd1306_128x32_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x32_fn, U8G_COM_SW_SPI);
245
+U8G_PB_DEV(u8g_dev_ssd1306_128x32_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x32_fn, U8G_COM_HW_SPI);
246
+U8G_PB_DEV(u8g_dev_ssd1306_128x32_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x32_fn, U8G_COM_SSD_I2C);
247
+

+ 237
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1306_128x64.c View File

@@ -0,0 +1,237 @@
1
+/*
2
+
3
+  u8g_dev_ssd1306_128x64.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+  
35
+*/
36
+
37
+#include "u8g.h"
38
+
39
+#define WIDTH 128
40
+#define HEIGHT 64
41
+#define PAGE_HEIGHT 8
42
+
43
+/* init sequence adafruit 128x64 OLED (NOT TESTED) */
44
+static const uint8_t u8g_dev_ssd1306_128x64_adafruit1_init_seq[] PROGMEM = {
45
+  U8G_ESC_CS(0),             /* disable chip */
46
+  U8G_ESC_ADR(0),           /* instruction mode */
47
+  U8G_ESC_RST(1),           /* do reset low pulse with (1*16)+2 milliseconds */
48
+  U8G_ESC_CS(1),             /* enable chip */
49
+
50
+  0x0ae,				/* display off, sleep mode */
51
+  0x0d5, 0x080,		/* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
52
+  0x0a8, 0x03f,		/* */
53
+
54
+  0x0d3, 0x000,		/*  */
55
+
56
+  0x040,				/* start line */
57
+  
58
+  0x08d, 0x010,		/* [1] charge pump setting (p62): 0x014 enable, 0x010 disable */
59
+
60
+  0x020, 0x000,		/* */
61
+  0x0a1,				/* segment remap a0/a1*/
62
+  0x0c8,				/* c0: scan dir normal, c8: reverse */
63
+  0x0da, 0x012,		/* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
64
+  0x081, 0x09f,		/* [1] set contrast control */
65
+  0x0d9, 0x022,		/* [1] pre-charge period 0x022/f1*/
66
+  0x0db, 0x040,		/* vcomh deselect level */
67
+  
68
+  0x02e,				/* 2012-05-27: Deactivate scroll */ 
69
+  0x0a4,				/* output ram to display */
70
+  0x0a6,				/* none inverted normal display mode */
71
+  0x0af,				/* display on */
72
+
73
+  U8G_ESC_CS(0),             /* disable chip */
74
+  U8G_ESC_END                /* end of sequence */
75
+};
76
+
77
+/* init sequence adafruit 128x64 OLED (NOT TESTED) */
78
+static const uint8_t u8g_dev_ssd1306_128x64_adafruit2_init_seq[] PROGMEM = {
79
+  U8G_ESC_CS(0),             /* disable chip */
80
+  U8G_ESC_ADR(0),           /* instruction mode */
81
+  U8G_ESC_RST(1),           /* do reset low pulse with (1*16)+2 milliseconds */
82
+  U8G_ESC_CS(1),             /* enable chip */
83
+
84
+  0x0ae,				/* display off, sleep mode */
85
+  0x0d5, 0x080,		/* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
86
+  0x0a8, 0x03f,		/* */
87
+
88
+  0x0d3, 0x000,		/*  */
89
+
90
+  0x040,				/* start line */
91
+  
92
+  0x08d, 0x014,		/* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */
93
+
94
+  0x020, 0x000,		/* */
95
+  0x0a1,				/* segment remap a0/a1*/
96
+  0x0c8,				/* c0: scan dir normal, c8: reverse */
97
+  0x0da, 0x012,		/* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
98
+  0x081, 0x0cf,		/* [2] set contrast control */
99
+  0x0d9, 0x0f1,		/* [2] pre-charge period 0x022/f1*/
100
+  0x0db, 0x040,		/* vcomh deselect level */
101
+  
102
+  0x02e,				/* 2012-05-27: Deactivate scroll */ 
103
+  0x0a4,				/* output ram to display */
104
+  0x0a6,				/* none inverted normal display mode */
105
+  0x0af,				/* display on */
106
+
107
+  U8G_ESC_CS(0),             /* disable chip */
108
+  U8G_ESC_END                /* end of sequence */
109
+};
110
+
111
+/* init sequence adafruit 128x64 OLED (NOT TESTED), like adafruit3, but with page addressing mode */
112
+static const uint8_t u8g_dev_ssd1306_128x64_adafruit3_init_seq[] PROGMEM = {
113
+  U8G_ESC_CS(0),             /* disable chip */
114
+  U8G_ESC_ADR(0),           /* instruction mode */
115
+  U8G_ESC_RST(1),           /* do reset low pulse with (1*16)+2 milliseconds */
116
+  U8G_ESC_CS(1),             /* enable chip */
117
+
118
+  0x0ae,				/* display off, sleep mode */
119
+  0x0d5, 0x080,		/* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
120
+  0x0a8, 0x03f,		/* */
121
+
122
+  0x0d3, 0x000,		/*  */
123
+
124
+  0x040,				/* start line */
125
+  
126
+  0x08d, 0x014,		/* [2] charge pump setting (p62): 0x014 enable, 0x010 disable */
127
+
128
+  0x020, 0x002,		/* 2012-05-27: page addressing mode */
129
+  0x0a1,				/* segment remap a0/a1*/
130
+  0x0c8,				/* c0: scan dir normal, c8: reverse */
131
+  0x0da, 0x012,		/* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
132
+  0x081, 0x0cf,		/* [2] set contrast control */
133
+  0x0d9, 0x0f1,		/* [2] pre-charge period 0x022/f1*/
134
+  0x0db, 0x040,		/* vcomh deselect level */
135
+  
136
+  0x02e,				/* 2012-05-27: Deactivate scroll */ 
137
+  0x0a4,				/* output ram to display */
138
+  0x0a6,				/* none inverted normal display mode */
139
+  0x0af,				/* display on */
140
+
141
+  U8G_ESC_CS(0),             /* disable chip */
142
+  U8G_ESC_END                /* end of sequence */
143
+};
144
+
145
+/* init sequence Univision datasheet (NOT TESTED) */
146
+static const uint8_t u8g_dev_ssd1306_128x64_univision_init_seq[] PROGMEM = {
147
+  U8G_ESC_CS(0),             /* disable chip */
148
+  U8G_ESC_ADR(0),           /* instruction mode */
149
+  U8G_ESC_RST(1),           /* do reset low pulse with (1*16)+2 milliseconds */
150
+  U8G_ESC_CS(1),             /* enable chip */
151
+
152
+  0x0ae,				/* display off, sleep mode */
153
+  0x0d5, 0x080,		/* clock divide ratio (0x00=1) and oscillator frequency (0x8) */
154
+  0x0a8, 0x03f,		/* multiplex ratio */
155
+  0x0d3, 0x000,		/* display offset */
156
+  0x040,				/* start line */
157
+  0x08d, 0x010,		/* charge pump setting (p62): 0x014 enable, 0x010 disable */
158
+  0x0a1,				/* segment remap a0/a1*/
159
+  0x0c8,				/* c0: scan dir normal, c8: reverse */
160
+  0x0da, 0x012,		/* com pin HW config, sequential com pin config (bit 4), disable left/right remap (bit 5) */
161
+  0x081, 0x09f,		/* set contrast control */
162
+  0x0d9, 0x022,		/* pre-charge period */
163
+  0x0db, 0x040,		/* vcomh deselect level */
164
+  0x022, 0x000,		/* page addressing mode WRONG: 3 byte cmd! */
165
+  0x0a4,				/* output ram to display */
166
+  0x0a6,				/* none inverted normal display mode */
167
+  0x0af,				/* display on */
168
+  U8G_ESC_CS(0),             /* disable chip */
169
+  U8G_ESC_END                /* end of sequence */
170
+};
171
+
172
+/* select one init sequence here */
173
+//#define u8g_dev_ssd1306_128x64_init_seq u8g_dev_ssd1306_128x64_univision_init_seq
174
+//#define u8g_dev_ssd1306_128x64_init_seq u8g_dev_ssd1306_128x64_adafruit1_init_seq
175
+//#define u8g_dev_ssd1306_128x64_init_seq u8g_dev_ssd1306_128x64_adafruit2_init_seq
176
+#define u8g_dev_ssd1306_128x64_init_seq u8g_dev_ssd1306_128x64_adafruit3_init_seq
177
+
178
+
179
+static const uint8_t u8g_dev_ssd1306_128x64_data_start[] PROGMEM = {
180
+  U8G_ESC_ADR(0),           /* instruction mode */
181
+  U8G_ESC_CS(1),             /* enable chip */
182
+  0x010,		/* set upper 4 bit of the col adr to 0 */
183
+  0x000,		/* set lower 4 bit of the col adr to 4  */
184
+  U8G_ESC_END                /* end of sequence */
185
+};
186
+
187
+static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = {
188
+  U8G_ESC_ADR(0),           /* instruction mode */
189
+  U8G_ESC_CS(1),             /* enable chip */
190
+  0x0ae,		/* display off */      
191
+  U8G_ESC_CS(1),             /* disable chip */
192
+  U8G_ESC_END                /* end of sequence */
193
+};
194
+
195
+static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
196
+  U8G_ESC_ADR(0),           /* instruction mode */
197
+  U8G_ESC_CS(1),             /* enable chip */
198
+  0x0af,		/* display on */      
199
+  U8G_ESC_DLY(50),       /* delay 50 ms */
200
+  U8G_ESC_CS(1),             /* disable chip */
201
+  U8G_ESC_END                /* end of sequence */
202
+};
203
+
204
+uint8_t u8g_dev_ssd1306_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
205
+{
206
+  switch(msg)
207
+  {
208
+    case U8G_DEV_MSG_INIT:
209
+      u8g_InitCom(u8g, dev);
210
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x64_init_seq);
211
+      break;
212
+    case U8G_DEV_MSG_STOP:
213
+      break;
214
+    case U8G_DEV_MSG_PAGE_NEXT:
215
+      {
216
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
217
+        u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1306_128x64_data_start);    
218
+        u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (SSD1306) */
219
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
220
+        if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
221
+          return 0;
222
+        u8g_SetChipSelect(u8g, dev, 0);
223
+      }
224
+      break;
225
+    case U8G_DEV_MSG_SLEEP_ON:
226
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);    
227
+      return 1;
228
+    case U8G_DEV_MSG_SLEEP_OFF:
229
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);    
230
+      return 1;
231
+  }
232
+  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
233
+}
234
+
235
+U8G_PB_DEV(u8g_dev_ssd1306_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x64_fn, U8G_COM_SW_SPI);
236
+U8G_PB_DEV(u8g_dev_ssd1306_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x64_fn, U8G_COM_HW_SPI);
237
+U8G_PB_DEV(u8g_dev_ssd1306_128x64_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1306_128x64_fn, U8G_COM_SSD_I2C);

+ 144
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1309_128x64.c View File

@@ -0,0 +1,144 @@
1
+/*
2
+
3
+  u8g_dev_ssd1309_128x64.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2012, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+  
35
+*/
36
+
37
+#include "u8g.h"
38
+
39
+#define WIDTH 128
40
+#define HEIGHT 64
41
+#define PAGE_HEIGHT 8
42
+
43
+
44
+/* ssd1309 ini sequence*/
45
+static const uint8_t u8g_dev_ssd1309_128x64_init_seq[] PROGMEM={
46
+	U8G_ESC_CS(0),             /* disable chip */
47
+	U8G_ESC_ADR(0),           /* instruction mode */
48
+	U8G_ESC_RST(1),           /* do reset low pulse with (1*16)+2 milliseconds */
49
+	U8G_ESC_CS(1),             /* enable chip */
50
+	
51
+	0xfd,0x12,		/*Command Lock */
52
+	0xae,			/*Set Display Off */
53
+	0xd5,0xa0,		/*set Display Clock Divide Ratio/Oscillator Frequency */
54
+	0xa8,0x3f,		/*Set Multiplex Ratio */
55
+	0x3d,0x00,		/*Set Display Offset*/
56
+	0x40,			/*Set Display Start Line*/
57
+	0xa1,			/*Set Segment Re-Map*/
58
+	0xc8,			/*Set COM Output Scan Direction*/
59
+	0xda,0x12,		/*Set COM Pins Hardware Configuration*/
60
+	0x81,0xdf,		/*Set Current Control */
61
+	0xd9,0x82,		/*Set Pre-Charge Period */
62
+	0xdb,0x34,		/*Set VCOMH Deselect Level */
63
+	0xa4,			/*Set Entire Display On/Off */
64
+	0xa6,			/*Set Normal/Inverse Display*/
65
+	U8G_ESC_VCC(1),	/*Power up VCC & Stabilized */
66
+	U8G_ESC_DLY(50),
67
+	0xaf,			/*Set Display On */
68
+	U8G_ESC_DLY(50),
69
+	U8G_ESC_CS(0),             /* disable chip */
70
+	U8G_ESC_END                /* end of sequence */
71
+};
72
+
73
+/* select one init sequence here */
74
+  #define u8g_dev_ssd1309_128x64_init_seq u8g_dev_ssd1309_128x64_init_seq
75
+  
76
+  
77
+ static const uint8_t u8g_dev_ssd1309_128x64_data_start[] PROGMEM = {
78
+  U8G_ESC_ADR(0),           /* instruction mode */
79
+  U8G_ESC_CS(1),             /* enable chip */
80
+  0x010,		/* set upper 4 bit of the col adr to 0 */
81
+  0x000,		/* set lower 4 bit of the col adr to 4  */
82
+  U8G_ESC_END                /* end of sequence */
83
+};
84
+
85
+static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = {
86
+  U8G_ESC_ADR(0),           /* instruction mode */
87
+  U8G_ESC_CS(1),             /* enable chip */
88
+  0x0ae,		/* display off */      
89
+  U8G_ESC_CS(1),             /* disable chip */
90
+  U8G_ESC_END                /* end of sequence */
91
+};
92
+
93
+static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
94
+  U8G_ESC_ADR(0),           /* instruction mode */
95
+  U8G_ESC_CS(1),             /* enable chip */
96
+  0x0af,		/* display on */      
97
+  U8G_ESC_DLY(50),       /* delay 50 ms */
98
+  U8G_ESC_CS(1),             /* disable chip */
99
+  U8G_ESC_END                /* end of sequence */
100
+};
101
+
102
+uint8_t u8g_dev_ssd1309_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
103
+{
104
+  switch(msg)
105
+  {
106
+    case U8G_DEV_MSG_INIT:
107
+      u8g_InitCom(u8g, dev);
108
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1309_128x64_init_seq);
109
+      break;
110
+    case U8G_DEV_MSG_STOP:
111
+      break;
112
+    case U8G_DEV_MSG_PAGE_NEXT:
113
+      {
114
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
115
+        u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1309_128x64_data_start);    
116
+        u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (SSD1306) */
117
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
118
+        if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
119
+          return 0;
120
+        u8g_SetChipSelect(u8g, dev, 0);
121
+      }
122
+      break;
123
+    case U8G_DEV_MSG_CONTRAST:
124
+      u8g_SetChipSelect(u8g, dev, 1);
125
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
126
+      u8g_WriteByte(u8g, dev, 0x081);
127
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
128
+      u8g_SetChipSelect(u8g, dev, 0);      
129
+      return 1; 
130
+    case U8G_DEV_MSG_SLEEP_ON:
131
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);    
132
+      return 1;
133
+    case U8G_DEV_MSG_SLEEP_OFF:
134
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);    
135
+      return 1;
136
+  }
137
+  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
138
+}
139
+
140
+U8G_PB_DEV(u8g_dev_ssd1309_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1309_128x64_fn, U8G_COM_HW_SPI);
141
+U8G_PB_DEV(u8g_dev_ssd1309_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1309_128x64_fn, U8G_COM_SW_SPI);
142
+U8G_PB_DEV(u8g_dev_ssd1309_128x64_i2c, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1309_128x64_fn, U8G_COM_SSD_I2C);
143
+ 
144
+  

+ 334
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1322_nhd31oled_bw.c View File

@@ -0,0 +1,334 @@
1
+/*
2
+
3
+  u8g_dev_ssd1322_nhd31oled_bw.c
4
+  
5
+  1-Bit (BW) Driver for SSD1322 Controller (OLED Display)
6
+  Tested with NHD-3.12-25664
7
+
8
+  Universal 8bit Graphics Library
9
+  
10
+  Copyright (c) 2012, olikraus@gmail.com
11
+  All rights reserved.
12
+
13
+  Redistribution and use in source and binary forms, with or without modification, 
14
+  are permitted provided that the following conditions are met:
15
+
16
+  * Redistributions of source code must retain the above copyright notice, this list 
17
+    of conditions and the following disclaimer.
18
+    
19
+  * Redistributions in binary form must reproduce the above copyright notice, this 
20
+    list of conditions and the following disclaimer in the documentation and/or other 
21
+    materials provided with the distribution.
22
+
23
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
24
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
25
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
26
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
27
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
28
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
29
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
30
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
31
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
32
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
33
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
34
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
35
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
36
+  
37
+  SSD130x       Monochrom OLED Controller
38
+  SSD131x       Character OLED Controller
39
+  SSD132x       Graylevel OLED Controller
40
+  SSD1331       Color OLED Controller       
41
+
42
+*/
43
+
44
+#include "u8g.h"
45
+
46
+/* width must be multiple of 8, largest value is 248 unless u8g 16 bit mode is enabled */
47
+#if defined(U8G_16BIT)
48
+#define WIDTH 256
49
+#else
50
+#define WIDTH 248
51
+#endif
52
+#define HEIGHT 64
53
+#define PAGE_HEIGHT 8
54
+
55
+/* 
56
+  http://www.newhavendisplay.com/app_notes/OLED_25664.txt 
57
+  http://www.newhavendisplay.com/forum/viewtopic.php?f=15&t=3758
58
+*/
59
+
60
+static const uint8_t u8g_dev_ssd1322_1bit_nhd_312_init_seq[] PROGMEM = {
61
+  U8G_ESC_DLY(10),              /* delay 10 ms */
62
+  U8G_ESC_CS(0),                 /* disable chip */
63
+  U8G_ESC_ADR(0),               /* instruction mode */
64
+  U8G_ESC_RST(1),               /* do reset low pulse with (1*16)+2 milliseconds */
65
+  U8G_ESC_CS(1),                /* enable chip */
66
+  
67
+  U8G_ESC_DLY(100),             /* delay 100 ms */
68
+  U8G_ESC_DLY(100),             /* delay 100 ms */
69
+  
70
+  U8G_ESC_ADR(0),               	/* instruction mode */
71
+  0x0fd,					/* lock command */
72
+  U8G_ESC_ADR(1),               	/* data mode */
73
+  0x012,					/* unlock */
74
+  
75
+  U8G_ESC_ADR(0),               	/* instruction mode */
76
+  0x0ae,                               	 /* display off, sleep mode */
77
+  
78
+  U8G_ESC_ADR(0),               	/* instruction mode */
79
+  0x0b3, 
80
+  U8G_ESC_ADR(1),               	/* data mode */
81
+  0x091,                    /* set display clock divide ratio/oscillator frequency (set clock as 80 frames/sec) */
82
+  
83
+  U8G_ESC_ADR(0),               	/* instruction mode */
84
+  0x0ca, 					/* multiplex ratio */
85
+  U8G_ESC_ADR(1),               	/* data mode */
86
+  0x03f,                    		/* 1/64 Duty (0x0F~0x3F) */
87
+  
88
+  U8G_ESC_ADR(0),               	/* instruction mode */
89
+  0x0a2, 
90
+  U8G_ESC_ADR(1),               	/* data mode */
91
+  0x000,                     		/* display offset, shift mapping ram counter */
92
+
93
+  U8G_ESC_ADR(0),               	/* instruction mode */
94
+  0x0a1, 
95
+  U8G_ESC_ADR(1),               	/* data mode */
96
+  0x000,                     		/* display start line */
97
+
98
+  U8G_ESC_ADR(0),               	/* instruction mode */
99
+  0x0a0, 					/* Set Re-Map / Dual COM Line Mode */
100
+  U8G_ESC_ADR(1),               	/* data mode */
101
+  0x014, 					/* was 0x014 */                     		
102
+  0x011, 					/* was 0x011 */	
103
+
104
+  U8G_ESC_ADR(0),               	/* instruction mode */
105
+  0x0ab, 
106
+  U8G_ESC_ADR(1),               	/* data mode */
107
+  0x001,                     		/* Enable Internal VDD Regulator */
108
+
109
+  U8G_ESC_ADR(0),               	/* instruction mode */
110
+  0x0b4, 					/* Display Enhancement A */
111
+  U8G_ESC_ADR(1),               	/* data mode */
112
+  0x0a0,                     		
113
+  0x005|0x0fd,                     		
114
+  
115
+  U8G_ESC_ADR(0),               	/* instruction mode */
116
+  0x0c1,					/* contrast */ 
117
+  U8G_ESC_ADR(1),               	/* data mode */
118
+  0x09f,                     		
119
+  
120
+  U8G_ESC_ADR(0),               	/* instruction mode */
121
+  0x0c7,					/* Set Scale Factor of Segment Output Current Control */ 
122
+  U8G_ESC_ADR(1),               	/* data mode */
123
+  0x00f,                     		
124
+
125
+  U8G_ESC_ADR(0),               	/* instruction mode */
126
+  0x0b9,                               	 /* linear gray scale */
127
+
128
+  U8G_ESC_ADR(0),               	/* instruction mode */
129
+  0x0b1,					/* Phase 1 (Reset) & Phase 2 (Pre-Charge) Period Adjustment */ 
130
+  U8G_ESC_ADR(1),               	/* data mode */
131
+  0x0e2,                     		
132
+
133
+  U8G_ESC_ADR(0),               	/* instruction mode */
134
+  0x0d1, 					/* Display Enhancement B */
135
+  U8G_ESC_ADR(1),               	/* data mode */
136
+  0x082|0x020,                     		
137
+  0x020,                     		
138
+
139
+  U8G_ESC_ADR(0),               	/* instruction mode */
140
+  0x0bb,					/* precharge  voltage */ 
141
+  U8G_ESC_ADR(1),               	/* data mode */
142
+  0x01f,                     		
143
+  
144
+  U8G_ESC_ADR(0),               	/* instruction mode */
145
+  0x0b6,					/* precharge period */ 
146
+  U8G_ESC_ADR(1),               	/* data mode */
147
+  0x008,                     		
148
+
149
+  U8G_ESC_ADR(0),               	/* instruction mode */
150
+  0x0be,					/* vcomh */ 
151
+  U8G_ESC_ADR(1),               	/* data mode */
152
+  0x007,                     		
153
+
154
+  U8G_ESC_ADR(0),               	/* instruction mode */
155
+  0x0a6,                               	 /* normal display */
156
+
157
+  U8G_ESC_ADR(0),               	/* instruction mode */
158
+  0x0a9,                               	 /* exit partial display */
159
+
160
+  U8G_ESC_ADR(0),               	/* instruction mode */
161
+  0x0af,                               	 /* display on */
162
+
163
+
164
+  U8G_ESC_CS(0),             /* disable chip */
165
+  U8G_ESC_END                /* end of sequence */
166
+};
167
+
168
+static const uint8_t u8g_dev_ssd1322_1bit_nhd_312_prepare_page_seq[] PROGMEM = {
169
+  U8G_ESC_ADR(0),               /* instruction mode */
170
+  U8G_ESC_CS(1),                /* enable chip */
171
+  0x015,       /* column address... */
172
+  U8G_ESC_ADR(1),               /* data mode */
173
+  0x01c,       /* start at column 0 */
174
+  0x05b,       /* end column */
175
+  U8G_ESC_ADR(0),               /* instruction mode */
176
+  0x075,       /* row address... */
177
+  U8G_ESC_ADR(1),               /* data mode */
178
+  U8G_ESC_END                /* end of sequence */
179
+};
180
+
181
+static void u8g_dev_ssd1322_1bit_prepare_row(u8g_t *u8g, u8g_dev_t *dev, uint8_t delta_row)
182
+{
183
+  uint8_t row = ((u8g_pb_t *)(dev->dev_mem))->p.page;
184
+  
185
+  row *= ((u8g_pb_t *)(dev->dev_mem))->p.page_height;
186
+  row += delta_row;
187
+  
188
+  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1322_1bit_nhd_312_prepare_page_seq);
189
+  
190
+  u8g_WriteByte(u8g, dev, row);       /* start at the selected row */
191
+  u8g_WriteByte(u8g, dev, row+1);       /* end within the selected row */  
192
+  
193
+  u8g_SetAddress(u8g, dev, 0);          /* instruction mode mode */
194
+  u8g_WriteByte(u8g, dev, 0x05c);       /* write to ram */  
195
+  u8g_SetAddress(u8g, dev, 1);          /* data mode */
196
+}
197
+
198
+static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = {
199
+  U8G_ESC_ADR(0),           /* instruction mode */
200
+  U8G_ESC_CS(1),             /* enable chip */
201
+  0x0ae,		/* display off */      
202
+  U8G_ESC_CS(1),             /* disable chip */
203
+  U8G_ESC_END                /* end of sequence */
204
+};
205
+
206
+static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
207
+  U8G_ESC_ADR(0),           /* instruction mode */
208
+  U8G_ESC_CS(1),             /* enable chip */
209
+  0x0af,		/* display on */      
210
+  U8G_ESC_DLY(50),       /* delay 50 ms */
211
+  U8G_ESC_CS(1),             /* disable chip */
212
+  U8G_ESC_END                /* end of sequence */
213
+};
214
+
215
+
216
+uint8_t u8g_dev_ssd1322_nhd31oled_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
217
+{
218
+  switch(msg)
219
+  {
220
+    case U8G_DEV_MSG_INIT:
221
+      u8g_InitCom(u8g, dev);
222
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1322_1bit_nhd_312_init_seq);
223
+      break;
224
+    case U8G_DEV_MSG_STOP:
225
+      break;
226
+    case U8G_DEV_MSG_PAGE_NEXT:
227
+      {
228
+	uint8_t i;
229
+	u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
230
+	uint8_t *p = pb->buf;
231
+	u8g_uint_t cnt;
232
+	cnt = pb->width;
233
+	cnt >>= 3;
234
+
235
+	for( i = 0; i < pb->p.page_height; i++ )
236
+	{
237
+	  u8g_dev_ssd1322_1bit_prepare_row(u8g, dev, i);  /* this will also enable chip select */
238
+#if !defined(U8G_16BIT)
239
+	  u8g_WriteByte(u8g, dev, 0x0ff);
240
+	  u8g_WriteByte(u8g, dev, 0x0ff);
241
+#endif
242
+	  u8g_WriteSequenceBWTo16GrDevice(u8g, dev, cnt, p);
243
+#if !defined(U8G_16BIT)
244
+	  u8g_WriteByte(u8g, dev, 0x0ff);
245
+	  u8g_WriteByte(u8g, dev, 0x0ff);
246
+#endif
247
+	  u8g_SetChipSelect(u8g, dev, 0);        
248
+	  p+=cnt;
249
+	}
250
+      }
251
+      break;
252
+    case U8G_DEV_MSG_CONTRAST:
253
+      u8g_SetChipSelect(u8g, dev, 1);
254
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
255
+      u8g_WriteByte(u8g, dev, 0x081);
256
+      u8g_SetAddress(u8g, dev, 1);          /* data mode */
257
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
258
+      u8g_SetChipSelect(u8g, dev, 0);      
259
+      break;
260
+    case U8G_DEV_MSG_SLEEP_ON:
261
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);    
262
+      return 1;
263
+    case U8G_DEV_MSG_SLEEP_OFF:
264
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);    
265
+      return 1;
266
+  }
267
+  return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg);
268
+}
269
+
270
+
271
+uint8_t u8g_dev_ssd1322_nhd31oled_2x_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
272
+{
273
+  switch(msg)
274
+  {
275
+    case U8G_DEV_MSG_INIT:
276
+      u8g_InitCom(u8g, dev);
277
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1322_1bit_nhd_312_init_seq);
278
+      break;
279
+    case U8G_DEV_MSG_STOP:
280
+      break;
281
+    case U8G_DEV_MSG_PAGE_NEXT:
282
+      {
283
+	uint8_t i;
284
+	u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
285
+	uint8_t *p = pb->buf;
286
+	u8g_uint_t cnt;
287
+	cnt = pb->width;
288
+	cnt >>= 3;
289
+
290
+	for( i = 0; i < pb->p.page_height; i++ )
291
+	{
292
+	  u8g_dev_ssd1322_1bit_prepare_row(u8g, dev, i);		/* this will also enable chip select */
293
+#if !defined(U8G_16BIT)
294
+	  u8g_WriteByte(u8g, dev, 0x0ff);
295
+	  u8g_WriteByte(u8g, dev, 0x0ff);
296
+#endif
297
+	  u8g_WriteSequenceBWTo16GrDevice(u8g, dev, cnt, p);
298
+#if !defined(U8G_16BIT)
299
+	  u8g_WriteByte(u8g, dev, 0x0ff);
300
+	  u8g_WriteByte(u8g, dev, 0x0ff);
301
+#endif
302
+	  u8g_SetChipSelect(u8g, dev, 0);        
303
+	  p+=cnt;
304
+	}
305
+      }
306
+      break;
307
+    case U8G_DEV_MSG_CONTRAST:
308
+      u8g_SetChipSelect(u8g, dev, 1);
309
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
310
+      u8g_WriteByte(u8g, dev, 0x081);
311
+      u8g_SetAddress(u8g, dev, 1);          /* data mode */
312
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
313
+      u8g_SetChipSelect(u8g, dev, 0);      
314
+      break;
315
+    case U8G_DEV_MSG_SLEEP_ON:
316
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);    
317
+      return 1;
318
+    case U8G_DEV_MSG_SLEEP_OFF:
319
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);    
320
+      return 1;
321
+  }
322
+  return u8g_dev_pb16h1_base_fn(u8g, dev, msg, arg);
323
+}
324
+
325
+
326
+U8G_PB_DEV(u8g_dev_ssd1322_nhd31oled_bw_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1322_nhd31oled_bw_fn, U8G_COM_SW_SPI);
327
+U8G_PB_DEV(u8g_dev_ssd1322_nhd31oled_bw_hw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1322_nhd31oled_bw_fn, U8G_COM_HW_SPI);
328
+
329
+#define DWIDTH (WIDTH*2)
330
+uint8_t u8g_dev_ssd1322_nhd31oled_2x_bw_buf[DWIDTH] U8G_NOCOMMON ; 
331
+u8g_pb_t u8g_dev_ssd1322_nhd31oled_2x_bw_pb = { {16, HEIGHT, 0, 0, 0},  WIDTH, u8g_dev_ssd1322_nhd31oled_2x_bw_buf}; 
332
+u8g_dev_t u8g_dev_ssd1322_nhd31oled_2x_bw_sw_spi = { u8g_dev_ssd1322_nhd31oled_2x_bw_fn, &u8g_dev_ssd1322_nhd31oled_2x_bw_pb, U8G_COM_SW_SPI };
333
+u8g_dev_t u8g_dev_ssd1322_nhd31oled_2x_bw_hw_spi = { u8g_dev_ssd1322_nhd31oled_2x_bw_fn, &u8g_dev_ssd1322_nhd31oled_2x_bw_pb, U8G_COM_HW_SPI };
334
+

+ 333
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1322_nhd31oled_gr.c View File

@@ -0,0 +1,333 @@
1
+/*
2
+
3
+  u8g_dev_ssd1322_nhd31oled_gr.c
4
+  
5
+  2-Bit (4L) Driver for SSD1322 Controller (OLED Display)
6
+  Tested with NHD-3.12-25664
7
+
8
+  Universal 8bit Graphics Library
9
+  
10
+  Copyright (c) 2012, olikraus@gmail.com
11
+  All rights reserved.
12
+
13
+  Redistribution and use in source and binary forms, with or without modification, 
14
+  are permitted provided that the following conditions are met:
15
+
16
+  * Redistributions of source code must retain the above copyright notice, this list 
17
+    of conditions and the following disclaimer.
18
+    
19
+  * Redistributions in binary form must reproduce the above copyright notice, this 
20
+    list of conditions and the following disclaimer in the documentation and/or other 
21
+    materials provided with the distribution.
22
+
23
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
24
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
25
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
26
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
27
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
28
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
29
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
30
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
31
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
32
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
33
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
34
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
35
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
36
+  
37
+  SSD130x       Monochrom OLED Controller
38
+  SSD131x       Character OLED Controller
39
+  SSD132x       Graylevel OLED Controller
40
+  SSD1331       Color OLED Controller       
41
+
42
+*/
43
+
44
+#include "u8g.h"
45
+
46
+/* width must be multiple of 8, largest value is 248 unless u8g 16 bit mode is enabled */
47
+#if defined(U8G_16BIT)
48
+#define WIDTH 256
49
+#else
50
+#define WIDTH 248
51
+#endif
52
+#define HEIGHT 64
53
+#define PAGE_HEIGHT 8
54
+
55
+/* 
56
+  http://www.newhavendisplay.com/app_notes/OLED_25664.txt 
57
+  http://www.newhavendisplay.com/forum/viewtopic.php?f=15&t=3758
58
+*/
59
+
60
+static const uint8_t u8g_dev_ssd1322_2bit_nhd_312_init_seq[] PROGMEM = {
61
+  U8G_ESC_DLY(10),              /* delay 10 ms */
62
+  U8G_ESC_CS(0),                 /* disable chip */
63
+  U8G_ESC_ADR(0),               /* instruction mode */
64
+  U8G_ESC_RST(1),               /* do reset low pulse with (1*16)+2 milliseconds */
65
+  U8G_ESC_CS(1),                /* enable chip */
66
+  
67
+  U8G_ESC_DLY(100),             /* delay 100 ms */
68
+  U8G_ESC_DLY(100),             /* delay 100 ms */
69
+  
70
+  U8G_ESC_ADR(0),               	/* instruction mode */
71
+  0x0fd,					/* lock command */
72
+  U8G_ESC_ADR(1),               	/* data mode */
73
+  0x012,					/* unlock */
74
+  
75
+  U8G_ESC_ADR(0),               	/* instruction mode */
76
+  0x0ae,                               	 /* display off, sleep mode */
77
+  
78
+  U8G_ESC_ADR(0),               	/* instruction mode */
79
+  0x0b3, 
80
+  U8G_ESC_ADR(1),               	/* data mode */
81
+  0x091,                    /* set display clock divide ratio/oscillator frequency (set clock as 80 frames/sec) */
82
+  
83
+  U8G_ESC_ADR(0),               	/* instruction mode */
84
+  0x0ca, 					/* multiplex ratio */
85
+  U8G_ESC_ADR(1),               	/* data mode */
86
+  0x03f,                    		/* 1/64 Duty (0x0F~0x3F) */
87
+  
88
+  U8G_ESC_ADR(0),               	/* instruction mode */
89
+  0x0a2, 
90
+  U8G_ESC_ADR(1),               	/* data mode */
91
+  0x000,                     		/* display offset, shift mapping ram counter */
92
+
93
+  U8G_ESC_ADR(0),               	/* instruction mode */
94
+  0x0a1, 
95
+  U8G_ESC_ADR(1),               	/* data mode */
96
+  0x000,                     		/* display start line */
97
+
98
+  U8G_ESC_ADR(0),               	/* instruction mode */
99
+  0x0a0, 					/* Set Re-Map / Dual COM Line Mode */
100
+  U8G_ESC_ADR(1),               	/* data mode */
101
+  0x014, 					/* was 0x014 */                     		
102
+  0x011, 					/* was 0x011 */	
103
+
104
+  U8G_ESC_ADR(0),               	/* instruction mode */
105
+  0x0ab, 
106
+  U8G_ESC_ADR(1),               	/* data mode */
107
+  0x001,                     		/* Enable Internal VDD Regulator */
108
+
109
+  U8G_ESC_ADR(0),               	/* instruction mode */
110
+  0x0b4, 					/* Display Enhancement A */
111
+  U8G_ESC_ADR(1),               	/* data mode */
112
+  0x0a0,                     		
113
+  0x005|0x0fd,                     		
114
+  
115
+  U8G_ESC_ADR(0),               	/* instruction mode */
116
+  0x0c1,					/* contrast */ 
117
+  U8G_ESC_ADR(1),               	/* data mode */
118
+  0x09f,                     		
119
+  
120
+  U8G_ESC_ADR(0),               	/* instruction mode */
121
+  0x0c7,					/* Set Scale Factor of Segment Output Current Control */ 
122
+  U8G_ESC_ADR(1),               	/* data mode */
123
+  0x00f,                     		
124
+
125
+  U8G_ESC_ADR(0),               	/* instruction mode */
126
+  0x0b9,                               	 /* linear gray scale */
127
+
128
+  U8G_ESC_ADR(0),               	/* instruction mode */
129
+  0x0b1,					/* Phase 1 (Reset) & Phase 2 (Pre-Charge) Period Adjustment */ 
130
+  U8G_ESC_ADR(1),               	/* data mode */
131
+  0x0e2,                     		
132
+
133
+  U8G_ESC_ADR(0),               	/* instruction mode */
134
+  0x0d1, 					/* Display Enhancement B */
135
+  U8G_ESC_ADR(1),               	/* data mode */
136
+  0x082|0x020,                     		
137
+  0x020,                     		
138
+
139
+  U8G_ESC_ADR(0),               	/* instruction mode */
140
+  0x0bb,					/* precharge  voltage */ 
141
+  U8G_ESC_ADR(1),               	/* data mode */
142
+  0x01f,                     		
143
+  
144
+  U8G_ESC_ADR(0),               	/* instruction mode */
145
+  0x0b6,					/* precharge period */ 
146
+  U8G_ESC_ADR(1),               	/* data mode */
147
+  0x008,                     		
148
+
149
+  U8G_ESC_ADR(0),               	/* instruction mode */
150
+  0x0be,					/* vcomh */ 
151
+  U8G_ESC_ADR(1),               	/* data mode */
152
+  0x007,                     		
153
+
154
+  U8G_ESC_ADR(0),               	/* instruction mode */
155
+  0x0a6,                               	 /* normal display */
156
+
157
+  U8G_ESC_ADR(0),               	/* instruction mode */
158
+  0x0a9,                               	 /* exit partial display */
159
+
160
+  U8G_ESC_ADR(0),               	/* instruction mode */
161
+  0x0af,                               	 /* display on */
162
+
163
+
164
+  U8G_ESC_CS(0),             /* disable chip */
165
+  U8G_ESC_END                /* end of sequence */
166
+};
167
+
168
+static const uint8_t u8g_dev_ssd1322_2bit_nhd_312_prepare_page_seq[] PROGMEM = {
169
+  U8G_ESC_ADR(0),               /* instruction mode */
170
+  U8G_ESC_CS(1),                /* enable chip */
171
+  0x015,       /* column address... */
172
+  U8G_ESC_ADR(1),               /* data mode */
173
+  0x01c,       /* start at column 0 */
174
+  0x05b,       /* end column */
175
+  U8G_ESC_ADR(0),               /* instruction mode */
176
+  0x075,       /* row address... */
177
+  U8G_ESC_ADR(1),               /* data mode */
178
+  U8G_ESC_END                /* end of sequence */
179
+};
180
+
181
+static void u8g_dev_ssd1322_2bit_prepare_row(u8g_t *u8g, u8g_dev_t *dev, uint8_t delta_row)
182
+{
183
+  uint8_t row = ((u8g_pb_t *)(dev->dev_mem))->p.page;
184
+  
185
+  row *= ((u8g_pb_t *)(dev->dev_mem))->p.page_height;
186
+  row += delta_row;
187
+  
188
+  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1322_2bit_nhd_312_prepare_page_seq);
189
+  
190
+  u8g_WriteByte(u8g, dev, row);       /* start at the selected row */
191
+  u8g_WriteByte(u8g, dev, row+1);       /* end within the selected row */  
192
+  
193
+  u8g_SetAddress(u8g, dev, 0);          /* instruction mode mode */
194
+  u8g_WriteByte(u8g, dev, 0x05c);       /* write to ram */  
195
+  u8g_SetAddress(u8g, dev, 1);          /* data mode */
196
+}
197
+
198
+static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = {
199
+  U8G_ESC_ADR(0),           /* instruction mode */
200
+  U8G_ESC_CS(1),             /* enable chip */
201
+  0x0ae,		/* display off */      
202
+  U8G_ESC_CS(1),             /* disable chip */
203
+  U8G_ESC_END                /* end of sequence */
204
+};
205
+
206
+static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
207
+  U8G_ESC_ADR(0),           /* instruction mode */
208
+  U8G_ESC_CS(1),             /* enable chip */
209
+  0x0af,		/* display on */      
210
+  U8G_ESC_DLY(50),       /* delay 50 ms */
211
+  U8G_ESC_CS(1),             /* disable chip */
212
+  U8G_ESC_END                /* end of sequence */
213
+};
214
+
215
+uint8_t u8g_dev_ssd1322_nhd31oled_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
216
+{
217
+  switch(msg)
218
+  {
219
+    case U8G_DEV_MSG_INIT:
220
+      u8g_InitCom(u8g, dev);
221
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1322_2bit_nhd_312_init_seq);
222
+      break;
223
+    case U8G_DEV_MSG_STOP:
224
+      break;
225
+    case U8G_DEV_MSG_PAGE_NEXT:
226
+      {
227
+	uint8_t i;
228
+	u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
229
+	uint8_t *p = pb->buf;
230
+	u8g_uint_t cnt;
231
+	cnt = pb->width;
232
+	cnt >>= 2;
233
+
234
+	for( i = 0; i < pb->p.page_height; i++ )
235
+	{
236
+	  u8g_dev_ssd1322_2bit_prepare_row(u8g, dev, i);  /* this will also enable chip select */
237
+#if !defined(U8G_16BIT)
238
+	  u8g_WriteByte(u8g, dev, 0x00);
239
+	  u8g_WriteByte(u8g, dev, 0x00);
240
+#endif
241
+	  u8g_WriteSequence4LTo16GrDevice(u8g, dev, cnt, p);
242
+#if !defined(U8G_16BIT)
243
+	  u8g_WriteByte(u8g, dev, 0x00);
244
+	  u8g_WriteByte(u8g, dev, 0x00);
245
+#endif
246
+	  u8g_SetChipSelect(u8g, dev, 0);        
247
+	  p+=cnt;
248
+	}
249
+      }
250
+      break;
251
+    case U8G_DEV_MSG_CONTRAST:
252
+      u8g_SetChipSelect(u8g, dev, 1);
253
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
254
+      u8g_WriteByte(u8g, dev, 0x081);
255
+      u8g_SetAddress(u8g, dev, 1);          /* data mode */
256
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
257
+      u8g_SetChipSelect(u8g, dev, 0);      
258
+      break;
259
+    case U8G_DEV_MSG_SLEEP_ON:
260
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);    
261
+      return 1;
262
+    case U8G_DEV_MSG_SLEEP_OFF:
263
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);    
264
+      return 1;
265
+  }
266
+  return u8g_dev_pb8h2_base_fn(u8g, dev, msg, arg);
267
+}
268
+
269
+
270
+uint8_t u8g_dev_ssd1322_nhd31oled_2x_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
271
+{
272
+  switch(msg)
273
+  {
274
+    case U8G_DEV_MSG_INIT:
275
+      u8g_InitCom(u8g, dev);
276
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1322_2bit_nhd_312_init_seq);
277
+      break;
278
+    case U8G_DEV_MSG_STOP:
279
+      break;
280
+    case U8G_DEV_MSG_PAGE_NEXT:
281
+      {
282
+	uint8_t i;
283
+	u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
284
+	uint8_t *p = pb->buf;
285
+	u8g_uint_t cnt;
286
+	cnt = pb->width;
287
+	cnt >>= 3;
288
+
289
+	for( i = 0; i < pb->p.page_height; i++ )
290
+	{
291
+	  u8g_dev_ssd1322_2bit_prepare_row(u8g, dev, i);		/* this will also enable chip select */
292
+#if !defined(U8G_16BIT)
293
+	  u8g_WriteByte(u8g, dev, 0x00);
294
+	  u8g_WriteByte(u8g, dev, 0x00);
295
+#endif
296
+	  u8g_WriteSequence4LTo16GrDevice(u8g, dev, cnt, p);
297
+#if !defined(U8G_16BIT)
298
+	  u8g_WriteByte(u8g, dev, 0x00);
299
+	  u8g_WriteByte(u8g, dev, 0x00);
300
+#endif
301
+	  u8g_SetChipSelect(u8g, dev, 0);        
302
+	  p+=cnt;
303
+	}
304
+      }
305
+      break;
306
+    case U8G_DEV_MSG_CONTRAST:
307
+      u8g_SetChipSelect(u8g, dev, 1);
308
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
309
+      u8g_WriteByte(u8g, dev, 0x081);
310
+      u8g_SetAddress(u8g, dev, 1);          /* data mode */
311
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
312
+      u8g_SetChipSelect(u8g, dev, 0);      
313
+      break;
314
+    case U8G_DEV_MSG_SLEEP_ON:
315
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);    
316
+      return 1;
317
+    case U8G_DEV_MSG_SLEEP_OFF:
318
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);    
319
+      return 1;
320
+  }
321
+  return u8g_dev_pb16h2_base_fn(u8g, dev, msg, arg);
322
+}
323
+
324
+
325
+U8G_PB_DEV(u8g_dev_ssd1322_nhd31oled_gr_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1322_nhd31oled_gr_fn, U8G_COM_SW_SPI);
326
+U8G_PB_DEV(u8g_dev_ssd1322_nhd31oled_gr_hw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1322_nhd31oled_gr_fn, U8G_COM_HW_SPI);
327
+
328
+#define DWIDTH (WIDTH*2)
329
+uint8_t u8g_dev_ssd1322_nhd31oled_2x_gr_buf[DWIDTH] U8G_NOCOMMON ; 
330
+u8g_pb_t u8g_dev_ssd1322_nhd31oled_2x_gr_pb = { {16, HEIGHT, 0, 0, 0},  WIDTH, u8g_dev_ssd1322_nhd31oled_2x_gr_buf}; 
331
+u8g_dev_t u8g_dev_ssd1322_nhd31oled_2x_gr_sw_spi = { u8g_dev_ssd1322_nhd31oled_2x_gr_fn, &u8g_dev_ssd1322_nhd31oled_2x_gr_pb, U8G_COM_SW_SPI };
332
+u8g_dev_t u8g_dev_ssd1322_nhd31oled_2x_gr_hw_spi = { u8g_dev_ssd1322_nhd31oled_2x_gr_fn, &u8g_dev_ssd1322_nhd31oled_2x_gr_pb, U8G_COM_HW_SPI };
333
+

+ 263
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1325_nhd27oled_bw.c View File

@@ -0,0 +1,263 @@
1
+/*
2
+
3
+  u8g_dev_ssd1325_nhd27oled_bw.c
4
+  
5
+  1-Bit (BW) Driver for SSD1325 Controller (OLED Display)
6
+  Tested with NHD-2.7-12864UCY3
7
+
8
+  Universal 8bit Graphics Library
9
+  
10
+  Copyright (c) 2011, olikraus@gmail.com
11
+  All rights reserved.
12
+
13
+  Redistribution and use in source and binary forms, with or without modification, 
14
+  are permitted provided that the following conditions are met:
15
+
16
+  * Redistributions of source code must retain the above copyright notice, this list 
17
+    of conditions and the following disclaimer.
18
+    
19
+  * Redistributions in binary form must reproduce the above copyright notice, this 
20
+    list of conditions and the following disclaimer in the documentation and/or other 
21
+    materials provided with the distribution.
22
+
23
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
24
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
25
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
26
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
27
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
28
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
29
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
30
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
31
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
32
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
33
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
34
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
35
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
36
+  
37
+  SSD130x       Monochrom OLED Controller
38
+  SSD131x       Character OLED Controller
39
+  SSD132x       Graylevel OLED Controller
40
+  SSD1331       Color OLED Controller       
41
+
42
+*/
43
+
44
+#ifdef OBSOLETE_CODE
45
+
46
+#include "u8g.h"
47
+
48
+#define WIDTH 128
49
+#define HEIGHT 64
50
+#define PAGE_HEIGHT 8
51
+
52
+/* http://www.newhavendisplay.com/app_notes/OLED_2_7_12864.txt */
53
+static const uint8_t u8g_dev_ssd1325_1bit_nhd_27_12864ucy3_init_seq[] PROGMEM = {
54
+  U8G_ESC_DLY(10),              /* delay 10 ms */
55
+  U8G_ESC_CS(0),                 /* disable chip */
56
+  U8G_ESC_ADR(0),               /* instruction mode */
57
+  U8G_ESC_RST(1),               /* do reset low pulse with (1*16)+2 milliseconds */
58
+  U8G_ESC_CS(1),                /* enable chip */
59
+  0x0ae,                                /* display off, sleep mode */
60
+  0x0b3, 0x091,                    /* set display clock divide ratio/oscillator frequency (set clock as 135 frames/sec) */
61
+  0x0a8, 0x03f,                     /* multiplex ratio: 0x03f * 1/64 duty */
62
+  0x0a2, 0x04c,                     /* display offset, shift mapping ram counter */
63
+  0x0a1, 0x000,                     /* display start line */
64
+  0x0ad, 0x002,                     /* master configuration: disable embedded DC-DC, enable internal VCOMH */
65
+  0x0a0, 0x056,                     /* remap configuration, vertical address increment, enable nibble remap (upper nibble is left) */
66
+  0x086,                                /* full current range (0x084, 0x085, 0x086) */
67
+  0x0b8,                                /* set gray scale table */
68
+      0x01, 0x011, 0x022, 0x032, 0x043, 0x054, 0x065, 0x076,
69
+  0x081, 0x070,                    /* contrast, brightness, 0..128, Newhaven: 0x040 */
70
+  0x0b2, 0x051,                    /* frame frequency (row period) */
71
+  0x0b1, 0x055,                    /* phase length */
72
+  0x0bc, 0x010,                    /* pre-charge voltage level */
73
+  0x0b4, 0x002,                    /* set pre-charge compensation level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
74
+  0x0b0, 0x028,                    /* enable pre-charge compensation (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
75
+  0x0be, 0x01c,                     /* VCOMH voltage */
76
+  0x0bf, 0x002|0x00d,           /* VSL voltage level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
77
+  0x0a5,                                 /* all pixel on */
78
+  0x0af,                                  /* display on */
79
+  U8G_ESC_DLY(100),             /* delay 100 ms */
80
+  U8G_ESC_DLY(100),             /* delay 100 ms */
81
+  0x0a4,                                 /* normal display mode */
82
+  U8G_ESC_CS(0),             /* disable chip */
83
+  U8G_ESC_END                /* end of sequence */
84
+};
85
+
86
+static const uint8_t u8g_dev_ssd1325_1bit_nhd_27_12864ucy3_prepare_page_seq[] PROGMEM = {
87
+  U8G_ESC_ADR(0),               /* instruction mode */
88
+  U8G_ESC_CS(1),                /* enable chip */
89
+  0x015,       /* column address... */
90
+  0x000,       /* start at column 0 */
91
+  0x03f,       /* end at column 63 (which is y == 127), because there are two pixel in one column */
92
+  0x075,       /* row address... */
93
+  U8G_ESC_END                /* end of sequence */
94
+};
95
+
96
+
97
+static void u8g_dev_ssd1325_1bit_prepare_page(u8g_t *u8g, u8g_dev_t *dev)
98
+{
99
+  uint8_t page = ((u8g_pb_t *)(dev->dev_mem))->p.page;
100
+  
101
+  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_1bit_nhd_27_12864ucy3_prepare_page_seq);
102
+  
103
+  page <<= 3;
104
+  u8g_WriteByte(u8g, dev, page);       /* start at the selected page */
105
+  page += 7;
106
+  u8g_WriteByte(u8g, dev, page);       /* end within the selected page */  
107
+  
108
+  u8g_SetAddress(u8g, dev, 1);          /* data mode */
109
+}
110
+
111
+static void u8g_dev_ssd1325_1bit_2x_prepare_page(u8g_t *u8g, u8g_dev_t *dev, uint8_t is_odd)
112
+{
113
+  uint8_t page = ((u8g_pb_t *)(dev->dev_mem))->p.page;
114
+  
115
+  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_1bit_nhd_27_12864ucy3_prepare_page_seq);
116
+  
117
+  page <<= 1;
118
+  page += is_odd;
119
+  
120
+  page <<= 3;
121
+  u8g_WriteByte(u8g, dev, page);       /* start at the selected page */
122
+  page += 7;
123
+  u8g_WriteByte(u8g, dev, page);       /* end within the selected page */  
124
+  
125
+  u8g_SetAddress(u8g, dev, 1);          /* data mode */
126
+}
127
+
128
+/* assumes row autoincrement and activated nibble remap */
129
+#ifdef OLD
130
+static  void _OLD_u8g_dev_ssd1325_1bit_write_16_pixel(u8g_t *u8g, u8g_dev_t *dev, uint8_t left, uint8_t right)
131
+{
132
+  uint8_t d, cnt;
133
+  cnt = 8;
134
+  do
135
+  {
136
+    d = 0;
137
+    if ( left & 1 )
138
+      d |= 0x0f0;
139
+    if ( right & 1 )
140
+      d |= 0x00f;
141
+    u8g_WriteByte(u8g, dev, d);
142
+    left >>= 1;
143
+    right >>= 1;
144
+    cnt--;
145
+  }while ( cnt > 0 );
146
+}
147
+#endif
148
+
149
+static  void u8g_dev_ssd1325_1bit_write_16_pixel(u8g_t *u8g, u8g_dev_t *dev, uint8_t left, uint8_t right)
150
+{
151
+  uint8_t d, cnt;
152
+  static uint8_t buf[8];
153
+  cnt = 8;
154
+  do
155
+  {
156
+    d = 0;
157
+    if ( left & 128 )
158
+      d |= 0x0f0;
159
+    if ( right & 128 )
160
+      d |= 0x00f;
161
+    cnt--;
162
+    buf[cnt] = d;
163
+    left <<= 1;
164
+    right <<= 1;
165
+  }while ( cnt > 0 );
166
+  u8g_WriteSequence(u8g, dev, 8, buf);
167
+}
168
+
169
+static void u8g_dev_ssd1325_1bit_write_buffer(u8g_t *u8g, u8g_dev_t *dev, uint8_t is_odd)
170
+{
171
+  uint8_t cnt, left, right;
172
+  uint8_t *ptr;
173
+  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
174
+  
175
+  ptr = pb->buf;
176
+  cnt = pb->width;
177
+  if ( is_odd )
178
+    ptr += cnt;
179
+  cnt >>= 1;
180
+  do
181
+  {
182
+    left = *ptr++;
183
+    right = *ptr++;
184
+    u8g_dev_ssd1325_1bit_write_16_pixel(u8g, dev, left, right);
185
+    cnt--;
186
+  } while( cnt > 0 );
187
+}
188
+
189
+uint8_t u8g_dev_ssd1325_nhd27oled_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
190
+{
191
+  switch(msg)
192
+  {
193
+    case U8G_DEV_MSG_INIT:
194
+      u8g_InitCom(u8g, dev);
195
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_1bit_nhd_27_12864ucy3_init_seq);
196
+      break;
197
+    case U8G_DEV_MSG_STOP:
198
+      break;
199
+    case U8G_DEV_MSG_PAGE_NEXT:
200
+      {
201
+        u8g_dev_ssd1325_1bit_prepare_page(u8g, dev);
202
+        u8g_dev_ssd1325_1bit_write_buffer(u8g, dev, 0);
203
+        u8g_SetChipSelect(u8g, dev, 0);        
204
+      }
205
+      break;
206
+    case U8G_DEV_MSG_CONTRAST:
207
+      u8g_SetChipSelect(u8g, dev, 1);
208
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
209
+      u8g_WriteByte(u8g, dev, 0x081);
210
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
211
+      u8g_SetChipSelect(u8g, dev, 0);      
212
+      break;
213
+  }
214
+  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
215
+}
216
+
217
+uint8_t u8g_dev_ssd1325_nhd27oled_2x_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
218
+{
219
+  switch(msg)
220
+  {
221
+    case U8G_DEV_MSG_INIT:
222
+      u8g_InitCom(u8g, dev);
223
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_1bit_nhd_27_12864ucy3_init_seq);
224
+      break;
225
+    case U8G_DEV_MSG_STOP:
226
+      break;
227
+    case U8G_DEV_MSG_PAGE_NEXT:
228
+      {
229
+        u8g_dev_ssd1325_1bit_2x_prepare_page(u8g, dev, 0);
230
+        u8g_dev_ssd1325_1bit_write_buffer(u8g, dev, 0);
231
+        u8g_dev_ssd1325_1bit_2x_prepare_page(u8g, dev, 1);
232
+        u8g_dev_ssd1325_1bit_write_buffer(u8g, dev, 1);
233
+        u8g_SetChipSelect(u8g, dev, 0);        
234
+      }
235
+      break;
236
+    case U8G_DEV_MSG_CONTRAST:
237
+      u8g_SetChipSelect(u8g, dev, 1);
238
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
239
+      u8g_WriteByte(u8g, dev, 0x081);
240
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
241
+      u8g_SetChipSelect(u8g, dev, 0);      
242
+      break;
243
+  }
244
+  return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
245
+}
246
+
247
+/* disabled, see bw_new.c */
248
+/*
249
+U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_bw_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1325_nhd27oled_bw_fn, U8G_COM_SW_SPI);
250
+U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_bw_hw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1325_nhd27oled_bw_fn, U8G_COM_HW_SPI);
251
+U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_bw_parallel , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_ssd1325_nhd27oled_bw_fn, U8G_COM_FAST_PARALLEL);
252
+*/
253
+
254
+/*
255
+uint8_t u8g_dev_ssd1325_nhd27oled_2x_bw_buf[WIDTH*2] U8G_NOCOMMON ; 
256
+u8g_pb_t u8g_dev_ssd1325_nhd27oled_2x_bw_pb = { {16, HEIGHT, 0, 0, 0},  WIDTH, u8g_dev_ssd1325_nhd27oled_2x_bw_buf}; 
257
+u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_sw_spi = { u8g_dev_ssd1325_nhd27oled_2x_bw_fn, &u8g_dev_ssd1325_nhd27oled_2x_bw_pb, U8G_COM_SW_SPI };
258
+u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_hw_spi = { u8g_dev_ssd1325_nhd27oled_2x_bw_fn, &u8g_dev_ssd1325_nhd27oled_2x_bw_pb, U8G_COM_HW_SPI };
259
+u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_parallel = { u8g_dev_ssd1325_nhd27oled_2x_bw_fn, &u8g_dev_ssd1325_nhd27oled_2x_bw_pb, U8G_COM_FAST_PARALLEL };
260
+*/
261
+
262
+#endif
263
+

+ 232
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1325_nhd27oled_bw_new.c View File

@@ -0,0 +1,232 @@
1
+/*
2
+
3
+  u8g_dev_ssd1325_nhd27oled_bw.c
4
+  
5
+  1-Bit (BW) Driver for SSD1325 Controller (OLED Display)
6
+  Horizontal architecture, completly rewritten
7
+  Tested with NHD-2.7-12864UCY3
8
+
9
+  Universal 8bit Graphics Library
10
+  
11
+  Copyright (c) 2012, olikraus@gmail.com
12
+  All rights reserved.
13
+
14
+  Redistribution and use in source and binary forms, with or without modification, 
15
+  are permitted provided that the following conditions are met:
16
+
17
+  * Redistributions of source code must retain the above copyright notice, this list 
18
+    of conditions and the following disclaimer.
19
+    
20
+  * Redistributions in binary form must reproduce the above copyright notice, this 
21
+    list of conditions and the following disclaimer in the documentation and/or other 
22
+    materials provided with the distribution.
23
+
24
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
25
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
26
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
27
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
28
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
29
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
30
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
31
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
32
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
33
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
34
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
35
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
36
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
37
+  
38
+  SSD130x       Monochrom OLED Controller
39
+  SSD131x       Character OLED Controller
40
+  SSD132x       Graylevel OLED Controller
41
+  SSD1331       Color OLED Controller       
42
+
43
+*/
44
+
45
+#include "u8g.h"
46
+
47
+/* width must be multiple of 8, largest value is 248 unless u8g 16 bit mode is enabled */
48
+#define WIDTH 128
49
+#define HEIGHT 64
50
+
51
+/* http://www.newhavendisplay.com/app_notes/OLED_2_7_12864.txt */
52
+static const uint8_t u8g_dev_ssd1325_nhd_27_12864_init_seq[] PROGMEM = {
53
+  U8G_ESC_DLY(10),              /* delay 10 ms */
54
+  U8G_ESC_CS(0),                 /* disable chip */
55
+  U8G_ESC_ADR(0),               /* instruction mode */
56
+  U8G_ESC_RST(1),               /* do reset low pulse with (1*16)+2 milliseconds */
57
+  U8G_ESC_CS(1),                /* enable chip */
58
+  0x0ae,                                /* display off, sleep mode */
59
+  0x0b3, 0x091,                    /* set display clock divide ratio/oscillator frequency (set clock as 135 frames/sec) */
60
+  0x0a8, 0x03f,                     /* multiplex ratio: 0x03f * 1/64 duty */
61
+  0x0a2, 0x04c,                     /* display offset, shift mapping ram counter */
62
+  0x0a1, 0x000,                     /* display start line */
63
+  0x0ad, 0x002,                     /* master configuration: disable embedded DC-DC, enable internal VCOMH */
64
+  0x0a0, 0x052,                     /* remap configuration, horizontal address increment (bit 2 = 0), enable nibble remap (upper nibble is left, bit 1 = 1) */
65
+  0x086,                                /* full current range (0x084, 0x085, 0x086) */
66
+  0x0b8,                                /* set gray scale table */
67
+      0x01, 0x011, 0x022, 0x032, 0x043, 0x054, 0x065, 0x076,
68
+  
69
+  0x081, 0x070,                    /* contrast, brightness, 0..128, Newhaven: 0x040 */
70
+  0x0b2, 0x051,                    /* frame frequency (row period) */
71
+  0x0b1, 0x055,                    /* phase length */
72
+  0x0bc, 0x010,                    /* pre-charge voltage level */
73
+  0x0b4, 0x002,                    /* set pre-charge compensation level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
74
+  0x0b0, 0x028,                    /* enable pre-charge compensation (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
75
+  0x0be, 0x01c,                     /* VCOMH voltage */
76
+  0x0bf, 0x002|0x00d,           /* VSL voltage level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
77
+  0x0a4,                                 /* normal display mode */
78
+  0x0af,                                  /* display on */
79
+  U8G_ESC_DLY(50),             /* delay 50 ms */
80
+  U8G_ESC_CS(0),             /* disable chip */
81
+  U8G_ESC_END                /* end of sequence */
82
+};
83
+
84
+static const uint8_t u8g_dev_ssd1325_prepare_row_seq[] PROGMEM = {
85
+  U8G_ESC_ADR(0),               /* instruction mode */
86
+  U8G_ESC_CS(1),                /* enable chip */
87
+  0x015,       /* column address... */
88
+  0x000,       /* start at column 0 */
89
+  0x03f,       /* end at column 63 (which is y == 127), because there are two pixel in one column */
90
+  0x075,       /* row address... */
91
+  U8G_ESC_END                /* end of sequence */
92
+};
93
+
94
+static void u8g_dev_ssd1325_prepare_row(u8g_t *u8g, u8g_dev_t *dev, uint8_t delta_row)
95
+{
96
+  uint8_t row = ((u8g_pb_t *)(dev->dev_mem))->p.page;
97
+  
98
+  row *= ((u8g_pb_t *)(dev->dev_mem))->p.page_height;
99
+  row += delta_row;
100
+  
101
+  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_prepare_row_seq);
102
+  
103
+  u8g_WriteByte(u8g, dev, row);       /* start at the selected row */
104
+  u8g_WriteByte(u8g, dev, row+1);       /* end within the selected row */  
105
+  
106
+  //u8g_SetAddress(u8g, dev, 0);          /* instruction mode mode */
107
+  //u8g_WriteByte(u8g, dev, 0x05c);       /* write to ram */  
108
+  u8g_SetAddress(u8g, dev, 1);          /* data mode */
109
+}
110
+
111
+static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = {
112
+  U8G_ESC_ADR(0),           /* instruction mode */
113
+  U8G_ESC_CS(1),             /* enable chip */
114
+  0x0ae,		/* display off */      
115
+  U8G_ESC_CS(1),             /* disable chip */
116
+  U8G_ESC_END                /* end of sequence */
117
+};
118
+
119
+static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
120
+  U8G_ESC_ADR(0),           /* instruction mode */
121
+  U8G_ESC_CS(1),             /* enable chip */
122
+  0x0af,		/* display on */      
123
+  U8G_ESC_DLY(50),       /* delay 50 ms */
124
+  U8G_ESC_CS(1),             /* disable chip */
125
+  U8G_ESC_END                /* end of sequence */
126
+};
127
+
128
+
129
+static uint8_t u8g_dev_ssd1325_nhd27oled_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
130
+{
131
+  switch(msg)
132
+  {
133
+    //case U8G_DEV_MSG_IS_BBX_INTERSECTION:
134
+    //  return u8g_pb_IsIntersection((u8g_pb_t *)(dev->dev_mem), (u8g_dev_arg_bbx_t *)arg);
135
+    case U8G_DEV_MSG_INIT:
136
+      u8g_InitCom(u8g, dev);
137
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_nhd_27_12864_init_seq);
138
+      break;
139
+    case U8G_DEV_MSG_STOP:
140
+      break;
141
+    case U8G_DEV_MSG_PAGE_NEXT:
142
+      {
143
+	uint8_t i;
144
+	u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
145
+	uint8_t *p = pb->buf;
146
+	u8g_uint_t cnt;
147
+	cnt = pb->width;
148
+	cnt >>= 3;
149
+
150
+	for( i = 0; i < pb->p.page_height; i++ )
151
+	{
152
+	  u8g_dev_ssd1325_prepare_row(u8g, dev, i);		/* this will also enable chip select */
153
+	  u8g_WriteSequenceBWTo16GrDevice(u8g, dev, cnt, p);
154
+	  u8g_SetChipSelect(u8g, dev, 0);        
155
+	  p+=cnt;
156
+	}
157
+      }
158
+      break;
159
+    case U8G_DEV_MSG_CONTRAST:
160
+      u8g_SetChipSelect(u8g, dev, 1);
161
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
162
+      u8g_WriteByte(u8g, dev, 0x081);
163
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
164
+      u8g_SetChipSelect(u8g, dev, 0);      
165
+      break;
166
+    case U8G_DEV_MSG_SLEEP_ON:
167
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);    
168
+      return 1;
169
+    case U8G_DEV_MSG_SLEEP_OFF:
170
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);    
171
+      return 1;
172
+  }
173
+  return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg);
174
+}
175
+
176
+static uint8_t u8g_dev_ssd1325_nhd27oled_2x_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
177
+{
178
+  switch(msg)
179
+  {
180
+    case U8G_DEV_MSG_INIT:
181
+      u8g_InitCom(u8g, dev);
182
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_nhd_27_12864_init_seq);
183
+      break;
184
+    case U8G_DEV_MSG_STOP:
185
+      break;
186
+    case U8G_DEV_MSG_PAGE_NEXT:
187
+      {
188
+	uint8_t i;
189
+	u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
190
+	uint8_t *p = pb->buf;
191
+	u8g_uint_t cnt;
192
+	cnt = pb->width;
193
+	cnt >>= 3;
194
+
195
+	for( i = 0; i < pb->p.page_height; i++ )
196
+	{
197
+	  u8g_dev_ssd1325_prepare_row(u8g, dev, i);		/* this will also enable chip select */
198
+	  u8g_WriteSequenceBWTo16GrDevice(u8g, dev, cnt, p);
199
+	  u8g_SetChipSelect(u8g, dev, 0);        
200
+	  p+=cnt;
201
+	}
202
+      }
203
+      break;
204
+    case U8G_DEV_MSG_CONTRAST:
205
+      u8g_SetChipSelect(u8g, dev, 1);
206
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
207
+      u8g_WriteByte(u8g, dev, 0x081);
208
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
209
+      u8g_SetChipSelect(u8g, dev, 0);      
210
+      break;
211
+    case U8G_DEV_MSG_SLEEP_ON:
212
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);    
213
+      return 1;
214
+    case U8G_DEV_MSG_SLEEP_OFF:
215
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);    
216
+      return 1;
217
+  }
218
+  return u8g_dev_pb16h1_base_fn(u8g, dev, msg, arg);
219
+}
220
+
221
+
222
+
223
+U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_bw_sw_spi , WIDTH, HEIGHT, 8, u8g_dev_ssd1325_nhd27oled_bw_fn, U8G_COM_SW_SPI);
224
+U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_bw_hw_spi , WIDTH, HEIGHT, 8, u8g_dev_ssd1325_nhd27oled_bw_fn, U8G_COM_HW_SPI);
225
+U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_bw_parallel , WIDTH, HEIGHT, 8, u8g_dev_ssd1325_nhd27oled_bw_fn, U8G_COM_FAST_PARALLEL);
226
+
227
+uint8_t u8g_dev_ssd1325_nhd27oled_2x_bw_buf[WIDTH*2] U8G_NOCOMMON ; 
228
+u8g_pb_t u8g_dev_ssd1325_nhd27oled_2x_bw_pb = { {16, HEIGHT, 0, 0, 0},  WIDTH, u8g_dev_ssd1325_nhd27oled_2x_bw_buf}; 
229
+u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_sw_spi = { u8g_dev_ssd1325_nhd27oled_2x_bw_fn, &u8g_dev_ssd1325_nhd27oled_2x_bw_pb, U8G_COM_SW_SPI };
230
+u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_hw_spi = { u8g_dev_ssd1325_nhd27oled_2x_bw_fn, &u8g_dev_ssd1325_nhd27oled_2x_bw_pb, U8G_COM_HW_SPI };
231
+u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_bw_parallel = { u8g_dev_ssd1325_nhd27oled_2x_bw_fn, &u8g_dev_ssd1325_nhd27oled_2x_bw_pb, U8G_COM_FAST_PARALLEL };
232
+

+ 255
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1325_nhd27oled_gr.c View File

@@ -0,0 +1,255 @@
1
+/*
2
+
3
+  u8g_dev_ssd1325_nhd27oled_gr.c
4
+  
5
+  2-Bit (gray level) Driver for SSD1325 Controller (OLED Display)
6
+  Tested with NHD-2.7-12864UCY3
7
+
8
+  Universal 8bit Graphics Library
9
+  
10
+  Copyright (c) 2011, olikraus@gmail.com
11
+  All rights reserved.
12
+
13
+  Redistribution and use in source and binary forms, with or without modification, 
14
+  are permitted provided that the following conditions are met:
15
+
16
+  * Redistributions of source code must retain the above copyright notice, this list 
17
+    of conditions and the following disclaimer.
18
+    
19
+  * Redistributions in binary form must reproduce the above copyright notice, this 
20
+    list of conditions and the following disclaimer in the documentation and/or other 
21
+    materials provided with the distribution.
22
+
23
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
24
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
25
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
26
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
27
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
28
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
29
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
30
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
31
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
32
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
33
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
34
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
35
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
36
+  
37
+  SSD130x       Monochrom OLED Controller
38
+  SSD131x       Character OLED Controller
39
+  SSD132x       Graylevel OLED Controller
40
+  SSD1331       Color OLED Controller       
41
+
42
+*/
43
+
44
+#ifdef OBSOLETE_CODE
45
+
46
+#include "u8g.h"
47
+
48
+#define WIDTH 128
49
+#define HEIGHT 64
50
+
51
+/* http://www.newhavendisplay.com/app_notes/OLED_2_7_12864.txt */
52
+static const uint8_t u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_init_seq[] PROGMEM = {
53
+  U8G_ESC_DLY(10),              /* delay 10 ms */
54
+  U8G_ESC_CS(0),                 /* disable chip */
55
+  U8G_ESC_ADR(0),               /* instruction mode */
56
+  U8G_ESC_RST(1),               /* do reset low pulse with (1*16)+2 milliseconds */
57
+  U8G_ESC_CS(1),                /* enable chip */
58
+  0x0ae,                                /* display off, sleep mode */
59
+  0x0b3, 0x091,                    /* set display clock divide ratio/oscillator frequency (set clock as 135 frames/sec) */
60
+  0x0a8, 0x03f,                     /* multiplex ratio: 0x03f * 1/64 duty */
61
+  0x0a2, 0x04c,                     /* display offset, shift mapping ram counter */
62
+  0x0a1, 0x000,                     /* display start line */
63
+  0x0ad, 0x002,                     /* master configuration: disable embedded DC-DC, enable internal VCOMH */
64
+  0x0a0, 0x056,                     /* remap configuration, vertical address increment, enable nibble remap (upper nibble is left) */
65
+  0x086,                                /* full current range (0x084, 0x085, 0x086) */
66
+  0x0b8,                                /* set gray scale table */
67
+      //0x01, 0x011, 0x022, 0x032, 0x043, 0x054, 0x065, 0x076,
68
+      0x01, 0x011, 0x022, 0x032, 0x043, 0x054, 0x077, 0x077,            // 4L mode uses 0, 2, 4, 7
69
+  0x081, 0x070,                    /* contrast, brightness, 0..128, Newhaven: 0x040 */
70
+  0x0b2, 0x051,                    /* frame frequency (row period) */
71
+  0x0b1, 0x055,                    /* phase length */
72
+  0x0bc, 0x010,                    /* pre-charge voltage level */
73
+  0x0b4, 0x002,                    /* set pre-charge compensation level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
74
+  0x0b0, 0x028,                    /* enable pre-charge compensation (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
75
+  0x0be, 0x01c,                     /* VCOMH voltage */
76
+  0x0bf, 0x002|0x00d,           /* VSL voltage level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
77
+  0x0a5,                                 /* all pixel on */
78
+  0x0af,                                  /* display on */
79
+  U8G_ESC_DLY(100),             /* delay 100 ms */
80
+  U8G_ESC_DLY(100),             /* delay 100 ms */
81
+  0x0a4,                                 /* normal display mode */
82
+  U8G_ESC_CS(0),             /* disable chip */
83
+  U8G_ESC_END                /* end of sequence */
84
+};
85
+
86
+static const uint8_t u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_prepare_page_seq[] PROGMEM = {
87
+  U8G_ESC_ADR(0),               /* instruction mode */
88
+  U8G_ESC_CS(1),                /* enable chip */
89
+  0x015,       /* column address... */
90
+  0x000,       /* start at column 0 */
91
+  0x03f,       /* end at column 63 (which is y == 127), because there are two pixel in one column */
92
+  0x075,       /* row address... */
93
+  U8G_ESC_END                /* end of sequence */
94
+};
95
+
96
+
97
+static void u8g_dev_ssd1325_2bit_prepare_page(u8g_t *u8g, u8g_dev_t *dev)
98
+{
99
+  uint8_t page = ((u8g_pb_t *)(dev->dev_mem))->p.page;
100
+  
101
+  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_prepare_page_seq);
102
+  
103
+  page <<= 2;
104
+  u8g_WriteByte(u8g, dev, page);       /* start at the selected page */
105
+  page += 3;
106
+  u8g_WriteByte(u8g, dev, page);       /* end within the selected page */  
107
+  
108
+  u8g_SetAddress(u8g, dev, 1);          /* data mode */
109
+}
110
+
111
+static void u8g_dev_ssd1325_2bit_2x_prepare_page(u8g_t *u8g, u8g_dev_t *dev, uint8_t is_odd)
112
+{
113
+  uint8_t page = ((u8g_pb_t *)(dev->dev_mem))->p.page;
114
+  
115
+  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_prepare_page_seq);
116
+  
117
+  page <<= 1;
118
+  page += is_odd;
119
+  
120
+  
121
+  page <<= 2;
122
+  u8g_WriteByte(u8g, dev, page);       /* start at the selected page */
123
+  page += 3;
124
+  u8g_WriteByte(u8g, dev, page);       /* end within the selected page */  
125
+  
126
+  u8g_SetAddress(u8g, dev, 1);          /* data mode */
127
+}
128
+
129
+/* assumes row autoincrement and activated nibble remap */
130
+static  void u8g_dev_ssd1325_2bit_write_4_pixel(u8g_t *u8g, u8g_dev_t *dev, uint8_t left, uint8_t right)
131
+{
132
+  uint8_t d, tmp, cnt;
133
+  cnt = 4;
134
+  do    
135
+  {
136
+    d = left;
137
+    d &= 3;
138
+    d <<= 4;    
139
+    tmp = right;    
140
+    tmp &= 3;
141
+    d |= tmp;
142
+    d <<= 2;
143
+    u8g_WriteByte(u8g, dev, d);
144
+    left >>= 2;
145
+    right >>= 2;
146
+    cnt--;
147
+  }while ( cnt > 0 );
148
+}
149
+
150
+static void u8g_dev_ssd1325_2bit_write_buffer(u8g_t *u8g, u8g_dev_t *dev)
151
+{
152
+  uint8_t cnt, left, right;
153
+  uint8_t *ptr;
154
+  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
155
+  
156
+  cnt = pb->width;
157
+  cnt >>= 1;
158
+  ptr = pb->buf;
159
+  do
160
+  {
161
+    left = *ptr++;
162
+    right = *ptr++;
163
+    u8g_dev_ssd1325_2bit_write_4_pixel(u8g, dev, left, right);
164
+    cnt--;
165
+  } while( cnt > 0 );
166
+}
167
+
168
+static void u8g_dev_ssd1325_2bit_2x_write_buffer(u8g_t *u8g, u8g_dev_t *dev, uint8_t is_odd)
169
+{
170
+  uint8_t cnt, left, right;
171
+  uint8_t *ptr;
172
+  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
173
+  
174
+  ptr = pb->buf;
175
+  cnt = pb->width;
176
+  if ( is_odd )
177
+    ptr += cnt;
178
+  cnt >>= 1;
179
+  do
180
+  {
181
+    left = *ptr++;
182
+    right = *ptr++;
183
+    u8g_dev_ssd1325_2bit_write_4_pixel(u8g, dev, left, right);
184
+    cnt--;
185
+  } while( cnt > 0 );
186
+}
187
+
188
+static uint8_t u8g_dev_ssd1325_nhd27oled_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
189
+{
190
+  switch(msg)
191
+  {
192
+    case U8G_DEV_MSG_INIT:
193
+      u8g_InitCom(u8g, dev);
194
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_init_seq);
195
+      break;
196
+    case U8G_DEV_MSG_STOP:
197
+      break;
198
+    case U8G_DEV_MSG_PAGE_NEXT:
199
+      {
200
+        u8g_dev_ssd1325_2bit_prepare_page(u8g, dev);
201
+        u8g_dev_ssd1325_2bit_write_buffer(u8g, dev);
202
+        u8g_SetChipSelect(u8g, dev, 0);        
203
+      }
204
+      break;
205
+    case U8G_DEV_MSG_CONTRAST:
206
+      u8g_SetChipSelect(u8g, dev, 1);
207
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
208
+      u8g_WriteByte(u8g, dev, 0x081);
209
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
210
+      u8g_SetChipSelect(u8g, dev, 0);      
211
+      return 1;
212
+  }
213
+  return u8g_dev_pb8v2_base_fn(u8g, dev, msg, arg);
214
+}
215
+
216
+static uint8_t u8g_dev_ssd1325_nhd27oled_2x_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
217
+{
218
+  switch(msg)
219
+  {
220
+    case U8G_DEV_MSG_INIT:
221
+      u8g_InitCom(u8g, dev);
222
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_init_seq);
223
+      break;
224
+    case U8G_DEV_MSG_STOP:
225
+      break;
226
+    case U8G_DEV_MSG_PAGE_NEXT:
227
+      {
228
+        u8g_dev_ssd1325_2bit_2x_prepare_page(u8g, dev, 0);
229
+        u8g_dev_ssd1325_2bit_2x_write_buffer(u8g, dev, 0);
230
+        u8g_dev_ssd1325_2bit_2x_prepare_page(u8g, dev, 1);
231
+        u8g_dev_ssd1325_2bit_2x_write_buffer(u8g, dev, 1);
232
+        u8g_SetChipSelect(u8g, dev, 0);        
233
+      }
234
+      break;
235
+    case U8G_DEV_MSG_CONTRAST:
236
+      u8g_SetChipSelect(u8g, dev, 1);
237
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
238
+      u8g_WriteByte(u8g, dev, 0x081);
239
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
240
+      u8g_SetChipSelect(u8g, dev, 0);      
241
+      return 1;
242
+  }
243
+  return u8g_dev_pb16v2_base_fn(u8g, dev, msg, arg);
244
+}
245
+
246
+//U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_gr_sw_spi , WIDTH, HEIGHT, 4, u8g_dev_ssd1325_nhd27oled_gr_fn, U8G_COM_SW_SPI);
247
+//U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_gr_hw_spi , WIDTH, HEIGHT, 4, u8g_dev_ssd1325_nhd27oled_gr_fn, U8G_COM_HW_SPI);
248
+
249
+//uint8_t u8g_dev_ssd1325_nhd27oled_2x_buf[WIDTH*2] U8G_NOCOMMON ; 
250
+//u8g_pb_t u8g_dev_ssd1325_nhd27oled_2x_pb = { {8, HEIGHT, 0, 0, 0},  WIDTH, u8g_dev_ssd1325_nhd27oled_2x_buf}; 
251
+//u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_gr_sw_spi = { u8g_dev_ssd1325_nhd27oled_2x_gr_fn, &u8g_dev_ssd1325_nhd27oled_2x_pb, U8G_COM_SW_SPI };
252
+//u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_gr_hw_spi = { u8g_dev_ssd1325_nhd27oled_2x_gr_fn, &u8g_dev_ssd1325_nhd27oled_2x_pb, U8G_COM_HW_SPI };
253
+
254
+
255
+#endif /* OBSOLETE_CODE */

+ 227
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1325_nhd27oled_gr_new.c View File

@@ -0,0 +1,227 @@
1
+/*
2
+
3
+  u8g_dev_ssd1325_nhd27oled_gr.c
4
+  
5
+  2-Bit (gray level) Driver for SSD1325 Controller (OLED Display)
6
+  Rewritten with new architecture
7
+  Tested with NHD-2.7-12864UCY3
8
+
9
+  Universal 8bit Graphics Library
10
+  
11
+  Copyright (c) 2011, olikraus@gmail.com
12
+  All rights reserved.
13
+
14
+  Redistribution and use in source and binary forms, with or without modification, 
15
+  are permitted provided that the following conditions are met:
16
+
17
+  * Redistributions of source code must retain the above copyright notice, this list 
18
+    of conditions and the following disclaimer.
19
+    
20
+  * Redistributions in binary form must reproduce the above copyright notice, this 
21
+    list of conditions and the following disclaimer in the documentation and/or other 
22
+    materials provided with the distribution.
23
+
24
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
25
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
26
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
27
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
28
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
29
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
30
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
31
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
32
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
33
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
34
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
35
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
36
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
37
+  
38
+  SSD130x       Monochrom OLED Controller
39
+  SSD131x       Character OLED Controller
40
+  SSD132x       Graylevel OLED Controller
41
+  SSD1331       Color OLED Controller       
42
+
43
+*/
44
+
45
+#include "u8g.h"
46
+
47
+#define WIDTH 128
48
+#define HEIGHT 64
49
+
50
+/* http://www.newhavendisplay.com/app_notes/OLED_2_7_12864.txt */
51
+static const uint8_t u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_init_seq[] PROGMEM = {
52
+  U8G_ESC_DLY(10),              /* delay 10 ms */
53
+  U8G_ESC_CS(0),                 /* disable chip */
54
+  U8G_ESC_ADR(0),               /* instruction mode */
55
+  U8G_ESC_RST(1),               /* do reset low pulse with (1*16)+2 milliseconds */
56
+  U8G_ESC_CS(1),                /* enable chip */
57
+  0x0ae,                                /* display off, sleep mode */
58
+  0x0b3, 0x091,                    /* set display clock divide ratio/oscillator frequency (set clock as 135 frames/sec) */
59
+  0x0a8, 0x03f,                     /* multiplex ratio: 0x03f * 1/64 duty */
60
+  0x0a2, 0x04c,                     /* display offset, shift mapping ram counter */
61
+  0x0a1, 0x000,                     /* display start line */
62
+  0x0ad, 0x002,                     /* master configuration: disable embedded DC-DC, enable internal VCOMH */
63
+  0x0a0, 0x052,                     /* remap configuration, horizontal address increment (bit 2 = 0), enable nibble remap (upper nibble is left, bit 1 = 1), old values: 0x0a0 0x0a6 */
64
+  0x086,                                /* full current range (0x084, 0x085, 0x086) */
65
+  0x0b8,                                /* set gray scale table */
66
+      //0x01, 0x011, 0x022, 0x032, 0x043, 0x054, 0x065, 0x076,
67
+      0x01, 0x011, 0x022, 0x032, 0x043, 0x054, 0x077, 0x077,            // 4L mode uses 0, 2, 4, 7
68
+  0x081, 0x070,                    /* contrast, brightness, 0..128, Newhaven: 0x040 */
69
+  0x0b2, 0x051,                    /* frame frequency (row period) */
70
+  0x0b1, 0x055,                    /* phase length */
71
+  0x0bc, 0x010,                    /* pre-charge voltage level */
72
+  0x0b4, 0x002,                    /* set pre-charge compensation level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
73
+  0x0b0, 0x028,                    /* enable pre-charge compensation (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
74
+  0x0be, 0x01c,                     /* VCOMH voltage */
75
+  0x0bf, 0x002|0x00d,           /* VSL voltage level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
76
+  0x0a4,                                 /* normal display mode */
77
+  0x0af,                                  /* display on */
78
+  U8G_ESC_DLY(50),             /* delay 50 ms */
79
+  U8G_ESC_CS(0),             /* disable chip */
80
+  U8G_ESC_END                /* end of sequence */
81
+};
82
+
83
+static const uint8_t u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_prepare_page_seq[] PROGMEM = {
84
+  U8G_ESC_ADR(0),               /* instruction mode */
85
+  U8G_ESC_CS(1),                /* enable chip */
86
+  0x015,       /* column address... */
87
+  0x000,       /* start at column 0 */
88
+  0x03f,       /* end at column 63 (which is y == 127), because there are two pixel in one column */
89
+  0x075,       /* row address... */
90
+  U8G_ESC_END                /* end of sequence */
91
+};
92
+
93
+static void u8g_dev_ssd1325_gr_prepare_row(u8g_t *u8g, u8g_dev_t *dev, uint8_t delta_row)
94
+{
95
+  uint8_t row = ((u8g_pb_t *)(dev->dev_mem))->p.page;
96
+  
97
+  row *= ((u8g_pb_t *)(dev->dev_mem))->p.page_height;
98
+  row += delta_row;
99
+  
100
+  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_prepare_page_seq);
101
+  
102
+  u8g_WriteByte(u8g, dev, row);       /* start at the selected row */
103
+  u8g_WriteByte(u8g, dev, row+1);       /* end within the selected row */  
104
+  
105
+  //u8g_SetAddress(u8g, dev, 0);          /* instruction mode mode */
106
+  //u8g_WriteByte(u8g, dev, 0x05c);       /* write to ram */  
107
+  u8g_SetAddress(u8g, dev, 1);          /* data mode */
108
+}
109
+
110
+static const uint8_t u8g_dev_ssd13xx_sleep_on[] PROGMEM = {
111
+  U8G_ESC_ADR(0),           /* instruction mode */
112
+  U8G_ESC_CS(1),             /* enable chip */
113
+  0x0ae,		/* display off */      
114
+  U8G_ESC_CS(1),             /* disable chip */
115
+  U8G_ESC_END                /* end of sequence */
116
+};
117
+
118
+static const uint8_t u8g_dev_ssd13xx_sleep_off[] PROGMEM = {
119
+  U8G_ESC_ADR(0),           /* instruction mode */
120
+  U8G_ESC_CS(1),             /* enable chip */
121
+  0x0af,		/* display on */      
122
+  U8G_ESC_DLY(50),       /* delay 50 ms */
123
+  U8G_ESC_CS(1),             /* disable chip */
124
+  U8G_ESC_END                /* end of sequence */
125
+};
126
+
127
+
128
+
129
+static uint8_t u8g_dev_ssd1325_nhd27oled_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
130
+{
131
+  switch(msg)
132
+  {
133
+    case U8G_DEV_MSG_INIT:
134
+      u8g_InitCom(u8g, dev);
135
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_init_seq);
136
+      break;
137
+    case U8G_DEV_MSG_STOP:
138
+      break;
139
+    case U8G_DEV_MSG_PAGE_NEXT:
140
+      {
141
+	uint8_t i;
142
+	u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
143
+	uint8_t *p = pb->buf;
144
+	u8g_uint_t cnt;
145
+	cnt = pb->width;
146
+	cnt >>= 2;
147
+
148
+	for( i = 0; i < pb->p.page_height; i++ )
149
+	{
150
+	  u8g_dev_ssd1325_gr_prepare_row(u8g, dev, i);		/* this will also enable chip select */
151
+	  u8g_WriteSequence4LTo16GrDevice(u8g, dev, cnt, p);
152
+	  u8g_SetChipSelect(u8g, dev, 0);        
153
+	  p+=cnt;
154
+	}
155
+      }
156
+      break;
157
+    case U8G_DEV_MSG_CONTRAST:
158
+      u8g_SetChipSelect(u8g, dev, 1);
159
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
160
+      u8g_WriteByte(u8g, dev, 0x081);
161
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
162
+      u8g_SetChipSelect(u8g, dev, 0);      
163
+      return 1;
164
+    case U8G_DEV_MSG_SLEEP_ON:
165
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);    
166
+      return 1;
167
+    case U8G_DEV_MSG_SLEEP_OFF:
168
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);    
169
+      return 1;
170
+  }
171
+  return u8g_dev_pb8h2_base_fn(u8g, dev, msg, arg);
172
+}
173
+
174
+
175
+
176
+static uint8_t u8g_dev_ssd1325_nhd27oled_2x_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
177
+{
178
+  switch(msg)
179
+  {
180
+    case U8G_DEV_MSG_INIT:
181
+      u8g_InitCom(u8g, dev);
182
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1325_2bit_nhd_27_12864ucy3_init_seq);
183
+      break;
184
+    case U8G_DEV_MSG_STOP:
185
+      break;
186
+    case U8G_DEV_MSG_PAGE_NEXT:
187
+      {
188
+	uint8_t i;
189
+	u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
190
+	uint8_t *p = pb->buf;
191
+	u8g_uint_t cnt;
192
+	cnt = pb->width;
193
+	cnt >>= 2;
194
+
195
+	for( i = 0; i < pb->p.page_height; i++ )
196
+	{
197
+	  u8g_dev_ssd1325_gr_prepare_row(u8g, dev, i);		/* this will also enable chip select */
198
+	  u8g_WriteSequence4LTo16GrDevice(u8g, dev, cnt, p);
199
+	  u8g_SetChipSelect(u8g, dev, 0);        
200
+	  p+=cnt;
201
+	}
202
+      }
203
+      break;
204
+    case U8G_DEV_MSG_CONTRAST:
205
+      u8g_SetChipSelect(u8g, dev, 1);
206
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
207
+      u8g_WriteByte(u8g, dev, 0x081);
208
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
209
+      u8g_SetChipSelect(u8g, dev, 0);      
210
+      return 1;
211
+    case U8G_DEV_MSG_SLEEP_ON:
212
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_on);    
213
+      return 1;
214
+    case U8G_DEV_MSG_SLEEP_OFF:
215
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd13xx_sleep_off);    
216
+      return 1;
217
+  }
218
+  return u8g_dev_pb16h2_base_fn(u8g, dev, msg, arg);
219
+}
220
+
221
+U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_gr_sw_spi , WIDTH, HEIGHT, 4, u8g_dev_ssd1325_nhd27oled_gr_fn, U8G_COM_SW_SPI);
222
+U8G_PB_DEV(u8g_dev_ssd1325_nhd27oled_gr_hw_spi , WIDTH, HEIGHT, 4, u8g_dev_ssd1325_nhd27oled_gr_fn, U8G_COM_HW_SPI);
223
+
224
+uint8_t u8g_dev_ssd1325_nhd27oled_2x_buf[WIDTH*2] U8G_NOCOMMON ; 
225
+u8g_pb_t u8g_dev_ssd1325_nhd27oled_2x_pb = { {8, HEIGHT, 0, 0, 0},  WIDTH, u8g_dev_ssd1325_nhd27oled_2x_buf}; 
226
+u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_gr_sw_spi = { u8g_dev_ssd1325_nhd27oled_2x_gr_fn, &u8g_dev_ssd1325_nhd27oled_2x_pb, U8G_COM_SW_SPI };
227
+u8g_dev_t u8g_dev_ssd1325_nhd27oled_2x_gr_hw_spi = { u8g_dev_ssd1325_nhd27oled_2x_gr_fn, &u8g_dev_ssd1325_nhd27oled_2x_pb, U8G_COM_HW_SPI };

+ 299
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1327_96x96_gr.c View File

@@ -0,0 +1,299 @@
1
+/*
2
+
3
+  u8g_dev_ssd1327_96x96_gr.c
4
+  
5
+  2-Bit (graylevel) Driver for SSD1327 Controller (OLED Display)
6
+  Tested with Seedstudio 96x96 Oled (LY120)
7
+  http://www.seeedstudio.com/wiki/index.php?title=Twig_-_OLED_96x96
8
+
9
+  Universal 8bit Graphics Library
10
+  
11
+  Copyright (c) 2012, olikraus@gmail.com
12
+  All rights reserved.
13
+
14
+  Redistribution and use in source and binary forms, with or without modification, 
15
+  are permitted provided that the following conditions are met:
16
+
17
+  * Redistributions of source code must retain the above copyright notice, this list 
18
+    of conditions and the following disclaimer.
19
+    
20
+  * Redistributions in binary form must reproduce the above copyright notice, this 
21
+    list of conditions and the following disclaimer in the documentation and/or other 
22
+    materials provided with the distribution.
23
+
24
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
25
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
26
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
27
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
28
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
29
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
30
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
31
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
32
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
33
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
34
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
35
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
36
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
37
+  
38
+  SSD130x       Monochrom OLED Controller
39
+  SSD131x       Character OLED Controller
40
+  SSD132x       Graylevel OLED Controller
41
+  SSD1331       Color OLED Controller       
42
+
43
+*/
44
+
45
+#include "u8g.h"
46
+
47
+#define WIDTH 96
48
+#define HEIGHT 96
49
+#define XOFFSET 8
50
+
51
+/*  
52
+  http://www.seeedstudio.com/wiki/index.php?title=Twig_-_OLED_96x96
53
+*/
54
+static const uint8_t u8g_dev_ssd1327_2bit_96x96_init_seq[] PROGMEM = {
55
+  U8G_ESC_DLY(10),              /* delay 10 ms */
56
+  U8G_ESC_CS(0),                 /* disable chip */
57
+  U8G_ESC_ADR(0),               /* instruction mode */
58
+  U8G_ESC_RST(1),               /* do reset low pulse with (1*16)+2 milliseconds */
59
+  U8G_ESC_CS(1),                /* enable chip */
60
+  0x0fd, 0x012,			/* unlock display, usually not required because the display is unlocked after reset */
61
+  0x0ae,             			/* display off, sleep mode */
62
+  0x0a8, 0x05f,			/* multiplex ratio: 0x05f * 1/64 duty */
63
+  0x0a1, 0x000,            		/* display start line */
64
+  0x0a2, 0x060,           		/* display offset, shift mapping ram counter */
65
+  //0x0a2, 0x04c,           		/* NHD: display offset, shift mapping ram counter */
66
+  0x0a0, 0x046,  			/* remap configuration, vertical address increment, enable nibble remap (upper nibble is left) */
67
+  //0x0a0, 0x056,  			/* NHD: remap configuration, vertical address increment, enable nibble remap (upper nibble is left) */
68
+  0x0ab, 0x001,			/* Enable internal VDD regulator (RESET) */
69
+  0x081, 0x053,          		/* contrast, brightness, 0..128, Newhaven: 0x040, LY120 0x053, 0x070 seems also ok */
70
+  0x0b1, 0x051,          		/* phase length */
71
+  0x0b3, 0x001,           		/* set display clock divide ratio/oscillator frequency */
72
+  0x0b9,					/* use linear lookup table */
73
+#if 0
74
+  0x0b8,                                /* set gray scale table */
75
+      //0x01, 0x011, 0x022, 0x032, 0x043, 0x054, 0x065, 0x076,
76
+      0x01, 0x011, 0x022, 0x032, 0x043, 0x054, 0x077, 0x077,            // 4L mode uses 0, 2, 4, 7
77
+#endif  
78
+  0x0bc, 0x008,                    	/* pre-charge voltage level */
79
+  0x0be, 0x007,                     	/* VCOMH voltage */
80
+  0x0b6, 0x001,			/* second precharge */
81
+  0x0d5, 0x062,			/* enable second precharge, internal vsl (bit0 = 0) */
82
+  
83
+#if 0
84
+  // the following commands are not used by the SeeedGrayOLED sequence */
85
+  0x0ad, 0x002,                     /* master configuration: disable embedded DC-DC, enable internal VCOMH */
86
+  0x086,                                /* full current range (0x084, 0x085, 0x086) */
87
+  0x0b2, 0x051,                    /* frame frequency (row period) */
88
+  0x0b4, 0x002,                    /* set pre-charge compensation level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
89
+  0x0b0, 0x028,                    /* enable pre-charge compensation (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
90
+  0x0bf, 0x002|0x00d,           /* VSL voltage level (not documented in the SDD1325 datasheet, but used in the NHD init seq.) */
91
+#endif 
92
+
93
+  0x0a5,                                 /* all pixel on */
94
+  //0x02e,					/* no scroll (according to SeeedGrayOLED sequence) */
95
+  0x0af,                                  /* display on */
96
+  U8G_ESC_DLY(100),             /* delay 100 ms */
97
+  0x0a4,                                 /* normal display mode */
98
+  U8G_ESC_DLY(100),             /* delay 100 ms */
99
+  0x0a5,                                 /* all pixel on */
100
+  0x0af,                                  /* display on */
101
+  U8G_ESC_DLY(100),             /* delay 100 ms */
102
+  0x0a4,                                 /* normal display mode */
103
+  
104
+  0x015,       /* column address... */
105
+  0x008,       /* start at column 8, special for the LY120 ??? */
106
+  0x037,       /* end at column 55, note: there are two pixel in one column */
107
+  
108
+  0x075,       /* row address... */
109
+  0x008,       
110
+  0x05f,       
111
+  
112
+  U8G_ESC_ADR(1),               /* data mode */
113
+  0x000f, 0x000f, 0x0000, 0x0000, 0x000f,0x000f,0x0000,0x0000,
114
+  0x000f, 0x000f, 0x0000, 0x0000, 0x000f,0x000f,0x0000,0x0000,
115
+  0x000f, 0x000f, 0x0000, 0x0000, 0x000f,0x000f,0x0000,0x0000,
116
+  0x000f, 0x000f, 0x0000, 0x0000, 0x000f,0x000f,0x0000,0x0000,
117
+  
118
+  U8G_ESC_CS(0),             /* disable chip */
119
+  U8G_ESC_END                /* end of sequence */
120
+};
121
+
122
+static const uint8_t u8g_dev_ssd1327_2bit_96x96_prepare_page_seq[] PROGMEM = {
123
+  U8G_ESC_ADR(0),               /* instruction mode */
124
+  U8G_ESC_CS(1),                /* enable chip */
125
+  0x015,       /* column address... */
126
+  XOFFSET,       /* start at column 8, special for the LY120 ??? */
127
+  0x037,       /* end at column 55, note: there are two pixel in one column */
128
+  0x075,       /* row address... */
129
+  U8G_ESC_END                /* end of sequence */
130
+};
131
+
132
+
133
+static void u8g_dev_ssd1327_2bit_prepare_page(u8g_t *u8g, u8g_dev_t *dev)
134
+{
135
+  uint8_t page = ((u8g_pb_t *)(dev->dev_mem))->p.page;
136
+  
137
+  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1327_2bit_96x96_prepare_page_seq);
138
+  
139
+  page <<= 2;
140
+  u8g_WriteByte(u8g, dev, page);       /* start at the selected page */
141
+  page += 3;
142
+  u8g_WriteByte(u8g, dev, page);       /* end within the selected page */  
143
+  
144
+  u8g_SetAddress(u8g, dev, 1);          /* data mode */
145
+}
146
+
147
+static void u8g_dev_ssd1327_2bit_2x_prepare_page(u8g_t *u8g, u8g_dev_t *dev, uint8_t is_odd)
148
+{
149
+  uint8_t page = ((u8g_pb_t *)(dev->dev_mem))->p.page;
150
+  
151
+  u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1327_2bit_96x96_prepare_page_seq);
152
+  
153
+  page <<= 1;
154
+  page += is_odd;
155
+  
156
+  page <<= 2;
157
+  u8g_WriteByte(u8g, dev, page);       /* start at the selected page */
158
+  page += 3;
159
+  u8g_WriteByte(u8g, dev, page);       /* end within the selected page */  
160
+  
161
+  u8g_SetAddress(u8g, dev, 1);          /* data mode */
162
+}
163
+
164
+/* assumes row autoincrement and activated nibble remap */
165
+static  void u8g_dev_ssd1327_2bit_write_4_pixel(u8g_t *u8g, u8g_dev_t *dev, uint8_t left, uint8_t right)
166
+{
167
+  uint8_t d, tmp, cnt;
168
+  static uint8_t buf[4];
169
+  buf[0] = 0;
170
+  buf[1] = 0;
171
+  buf[2] = 0;
172
+  buf[3] = 0;
173
+  cnt = 0;
174
+  do 
175
+  {
176
+    if ( left == 0 && right == 0 )
177
+      break;
178
+    d = left;
179
+    d &= 3;
180
+    d <<= 4;    
181
+    tmp = right;    
182
+    tmp &= 3;
183
+    d |= tmp;
184
+    d <<= 2;
185
+    buf[cnt] = d;
186
+    left >>= 2;
187
+    right >>= 2;
188
+    cnt++;
189
+  }while ( cnt < 4 );
190
+  u8g_WriteSequence(u8g, dev, 4, buf);
191
+}
192
+
193
+static void u8g_dev_ssd1327_2bit_write_buffer(u8g_t *u8g, u8g_dev_t *dev)
194
+{
195
+  uint8_t cnt, left, right;
196
+  uint8_t *ptr;
197
+  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
198
+  
199
+  cnt = pb->width;
200
+  cnt >>= 1;
201
+  ptr = pb->buf;
202
+  do
203
+  {
204
+    left = *ptr++;
205
+    right = *ptr++;
206
+    u8g_dev_ssd1327_2bit_write_4_pixel(u8g, dev, left, right);
207
+    cnt--;
208
+  } while( cnt > 0 );
209
+}
210
+
211
+static void u8g_dev_ssd1327_2bit_2x_write_buffer(u8g_t *u8g, u8g_dev_t *dev, uint8_t is_odd)
212
+{
213
+  uint8_t cnt, left, right;
214
+  uint8_t *ptr;
215
+  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
216
+  
217
+  ptr = pb->buf;
218
+  cnt = pb->width;
219
+  if ( is_odd )
220
+    ptr += cnt;
221
+  cnt >>= 1;
222
+  do
223
+  {
224
+    left = *ptr++;
225
+    right = *ptr++;
226
+    u8g_dev_ssd1327_2bit_write_4_pixel(u8g, dev, left, right);
227
+    cnt--;
228
+  } while( cnt > 0 );
229
+}
230
+
231
+uint8_t u8g_dev_ssd1327_96x96_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
232
+{
233
+  switch(msg)
234
+  {
235
+    case U8G_DEV_MSG_INIT:
236
+      u8g_InitCom(u8g, dev);
237
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1327_2bit_96x96_init_seq);
238
+      break;
239
+    case U8G_DEV_MSG_STOP:
240
+      break;
241
+    case U8G_DEV_MSG_PAGE_NEXT:
242
+      {
243
+        u8g_dev_ssd1327_2bit_prepare_page(u8g, dev);
244
+        u8g_dev_ssd1327_2bit_write_buffer(u8g, dev);
245
+        u8g_SetChipSelect(u8g, dev, 0);        
246
+      }
247
+      break;
248
+    case U8G_DEV_MSG_CONTRAST:
249
+      u8g_SetChipSelect(u8g, dev, 1);
250
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
251
+      u8g_WriteByte(u8g, dev, 0x081);
252
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
253
+      u8g_SetChipSelect(u8g, dev, 0);      
254
+      return 1;
255
+  }
256
+  return u8g_dev_pb8v2_base_fn(u8g, dev, msg, arg);
257
+}
258
+
259
+uint8_t u8g_dev_ssd1327_96x96_2x_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
260
+{
261
+  switch(msg)
262
+  {
263
+    case U8G_DEV_MSG_INIT:
264
+      u8g_InitCom(u8g, dev);
265
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_ssd1327_2bit_96x96_init_seq);
266
+      break;
267
+    case U8G_DEV_MSG_STOP:
268
+      break;
269
+    case U8G_DEV_MSG_PAGE_NEXT:
270
+      {
271
+        u8g_dev_ssd1327_2bit_2x_prepare_page(u8g, dev, 0);
272
+        u8g_dev_ssd1327_2bit_2x_write_buffer(u8g, dev, 0);
273
+        u8g_dev_ssd1327_2bit_2x_prepare_page(u8g, dev, 1);
274
+        u8g_dev_ssd1327_2bit_2x_write_buffer(u8g, dev, 1);
275
+        u8g_SetChipSelect(u8g, dev, 0);        
276
+      }
277
+      break;
278
+    case U8G_DEV_MSG_CONTRAST:
279
+      u8g_SetChipSelect(u8g, dev, 1);
280
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
281
+      u8g_WriteByte(u8g, dev, 0x081);
282
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
283
+      u8g_SetChipSelect(u8g, dev, 0);      
284
+      return 1;
285
+  }
286
+  return u8g_dev_pb16v2_base_fn(u8g, dev, msg, arg);
287
+}
288
+
289
+U8G_PB_DEV(u8g_dev_ssd1327_96x96_gr_sw_spi , WIDTH, HEIGHT, 4, u8g_dev_ssd1327_96x96_gr_fn, U8G_COM_SW_SPI);
290
+U8G_PB_DEV(u8g_dev_ssd1327_96x96_gr_hw_spi , WIDTH, HEIGHT, 4, u8g_dev_ssd1327_96x96_gr_fn, U8G_COM_HW_SPI);
291
+U8G_PB_DEV(u8g_dev_ssd1327_96x96_gr_i2c , WIDTH, HEIGHT, 4, u8g_dev_ssd1327_96x96_gr_fn, U8G_COM_SSD_I2C);
292
+
293
+#define DWIDTH (2*WIDTH)
294
+uint8_t u8g_dev_ssd1327_96x96_2x_buf[DWIDTH] U8G_NOCOMMON ; 
295
+u8g_pb_t u8g_dev_ssd1327_96x96_2x_pb = { {8, HEIGHT, 0, 0, 0},  WIDTH, u8g_dev_ssd1327_96x96_2x_buf}; 
296
+u8g_dev_t u8g_dev_ssd1327_96x96_2x_gr_sw_spi = { u8g_dev_ssd1327_96x96_2x_gr_fn, &u8g_dev_ssd1327_96x96_2x_pb, U8G_COM_SW_SPI };
297
+u8g_dev_t u8g_dev_ssd1327_96x96_2x_gr_hw_spi = { u8g_dev_ssd1327_96x96_2x_gr_fn, &u8g_dev_ssd1327_96x96_2x_pb, U8G_COM_HW_SPI };
298
+u8g_dev_t u8g_dev_ssd1327_96x96_2x_gr_i2c = { u8g_dev_ssd1327_96x96_2x_gr_fn, &u8g_dev_ssd1327_96x96_2x_pb, U8G_COM_SSD_I2C };
299
+

+ 153
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7565_64128n.c View File

@@ -0,0 +1,153 @@
1
+/*
2
+
3
+  u8g_dev_st7565_64128n.c (Displaytech)
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+  
35
+*/
36
+
37
+#include "u8g.h"
38
+
39
+#define WIDTH 128
40
+#define HEIGHT 64
41
+#define PAGE_HEIGHT 8
42
+
43
+/* init sequence from https://github.com/adafruit/ST7565-LCD/blob/master/ST7565/ST7565.cpp */
44
+static const uint8_t u8g_dev_st7565_64128n_init_seq[] PROGMEM = {
45
+ 	 U8G_ESC_CS(0),            /* disable chip */
46
+	  U8G_ESC_ADR(0),          /* instruction mode */
47
+	  U8G_ESC_CS(1),           /* enable chip */
48
+	  U8G_ESC_RST(15),         /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
49
+
50
+	  0x0A2,   				   /* 0x0a2: LCD bias 1/9 (according to Displaytech 64128N datasheet) */
51
+	  0x0A0,  				   /* Normal ADC Select (according to Displaytech 64128N datasheet) */
52
+
53
+	  0x0c8,                   /* common output mode: set scan direction normal operation/SHL Select, 0x0c0 --> SHL = 0, normal, 0x0c8 --> SHL = 1 */
54
+	  0x040,		           /* Display start line for Displaytech 64128N */
55
+
56
+	  0x028 | 0x04,            /* power control: turn on voltage converter */
57
+	  U8G_ESC_DLY(50),         /* delay 50 ms */
58
+
59
+	  0x028 | 0x06,            /* power control: turn on voltage regulator */
60
+	  U8G_ESC_DLY(50),         /* delay 50 ms */
61
+
62
+	  0x028 | 0x07,            /* power control: turn on voltage follower */
63
+	  U8G_ESC_DLY(50),         /* delay 50 ms */
64
+
65
+	  0x010,                   /* Set V0 voltage resistor ratio. Setting for controlling brightness of Displaytech 64128N */
66
+
67
+	  0x0a6,                   /* display normal, bit val 0: LCD pixel off. */
68
+
69
+	  0x081,      	           /* set contrast */
70
+	  0x01e,        	       /* Contrast value. Setting for controlling brightness of Displaytech 64128N */
71
+
72
+
73
+	  0x0af,		           /* display on */
74
+
75
+	  U8G_ESC_DLY(100),        /* delay 100 ms */
76
+	  0x0a5,		           /* display all points, ST7565 */
77
+	  U8G_ESC_DLY(100),        /* delay 100 ms */
78
+	  U8G_ESC_DLY(100),        /* delay 100 ms */
79
+	  0x0a4,		           /* normal display */
80
+	  U8G_ESC_CS(0),           /* disable chip */
81
+	  U8G_ESC_END              /* end of sequence */
82
+};
83
+
84
+static const uint8_t u8g_dev_st7565_64128n_data_start[] PROGMEM = {
85
+  U8G_ESC_ADR(0),           /* instruction mode */
86
+  U8G_ESC_CS(1),            /* enable chip */
87
+  0x010,	                /* set upper 4 bit of the col adr to 0x10 */
88
+  0x000,		            /* set lower 4 bit of the col adr to 0x00. Changed for DisplayTech 64128N */      
89
+  U8G_ESC_END               /* end of sequence */
90
+};
91
+
92
+static const uint8_t u8g_dev_st7565_64128n_sleep_on[] PROGMEM = {
93
+  U8G_ESC_ADR(0),           /* instruction mode */
94
+  U8G_ESC_CS(1),             /* enable chip */
95
+  0x0ac,		/* static indicator off */
96
+  0x000,		                /* indicator register set (not sure if this is required) */
97
+  0x0ae,		/* display off */      
98
+  0x0a5,		/* all points on */      
99
+  U8G_ESC_CS(1),             /* disable chip */
100
+  U8G_ESC_END                /* end of sequence */
101
+};
102
+
103
+static const uint8_t u8g_dev_st7565_64128n_sleep_off[] PROGMEM = {
104
+  U8G_ESC_ADR(0),           /* instruction mode */
105
+  U8G_ESC_CS(1),             /* enable chip */
106
+  0x0a4,		/* all points off */      
107
+  0x0af,		/* display on */      
108
+  U8G_ESC_DLY(50),       /* delay 50 ms */
109
+  U8G_ESC_CS(1),             /* disable chip */
110
+  U8G_ESC_END                /* end of sequence */
111
+};
112
+
113
+uint8_t u8g_dev_st7565_64128n_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
114
+{
115
+  switch(msg)
116
+  {
117
+    case U8G_DEV_MSG_INIT:
118
+      u8g_InitCom(u8g, dev);
119
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_64128n_init_seq);
120
+      break;
121
+    case U8G_DEV_MSG_STOP:
122
+      break;
123
+    case U8G_DEV_MSG_PAGE_NEXT:
124
+      {
125
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
126
+        u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_64128n_data_start);    
127
+        u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
128
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
129
+        if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
130
+          return 0;
131
+        u8g_SetChipSelect(u8g, dev, 0);
132
+      }
133
+      break;
134
+    case U8G_DEV_MSG_CONTRAST:
135
+      u8g_SetChipSelect(u8g, dev, 1);
136
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
137
+      u8g_WriteByte(u8g, dev, 0x081);
138
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
139
+      u8g_SetChipSelect(u8g, dev, 0);      
140
+      return 1;
141
+    case U8G_DEV_MSG_SLEEP_ON:
142
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_64128n_sleep_on);    
143
+      return 1;
144
+    case U8G_DEV_MSG_SLEEP_OFF:
145
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_64128n_sleep_off);    
146
+      return 1;
147
+  }
148
+  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
149
+}
150
+
151
+U8G_PB_DEV(u8g_dev_st7565_64128n_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_64128n_fn, U8G_COM_SW_SPI);
152
+U8G_PB_DEV(u8g_dev_st7565_64128n_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_64128n_fn, U8G_COM_HW_SPI);
153
+

+ 140
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7565_dogm128.c View File

@@ -0,0 +1,140 @@
1
+/*
2
+
3
+  u8g_dev_st7565_dogm128.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+  
35
+*/
36
+
37
+#include "u8g.h"
38
+
39
+#define WIDTH 128
40
+#define HEIGHT 64
41
+#define PAGE_HEIGHT 8
42
+
43
+const uint8_t u8g_dev_st7565_dogm128_init_seq[] PROGMEM = {
44
+  U8G_ESC_CS(0),             /* disable chip */
45
+  U8G_ESC_ADR(0),           /* instruction mode */
46
+  U8G_ESC_RST(1),           /* do reset low pulse with (1*16)+2 milliseconds */
47
+  U8G_ESC_CS(1),             /* enable chip */
48
+  
49
+  0x040,		                /* set display start line */
50
+  0x0a1,		                /* ADC set to reverse */
51
+  0x0c0,		                /* common output mode: set scan direction normal operation */
52
+  0x0a6,                           /* display normal (none reverse) */
53
+  0x0a2,		                /* LCD bias 1/9 */
54
+  0x02f,		                /* all power  control circuits on */
55
+  0x0f8,		                /* set booster ratio to */
56
+  0x000,		                /* 4x */
57
+  0x027,		                /* set V0 voltage resistor ratio to large */
58
+  0x081,		                /* set contrast */
59
+  0x018,		                /* contrast value, EA default: 0x016 */
60
+  0x0ac,		                /* indicator */
61
+  0x000,		                /* disable */
62
+  0x0a4,		                /* normal display (not all on) */
63
+  0x0af,		                /* display on */
64
+  U8G_ESC_DLY(50),       /* delay 50 ms */
65
+
66
+  U8G_ESC_CS(0),             /* disable chip */
67
+  U8G_ESC_END                /* end of sequence */
68
+};
69
+
70
+static const uint8_t u8g_dev_st7565_dogm128_data_start[] PROGMEM = {
71
+  U8G_ESC_ADR(0),           /* instruction mode */
72
+  U8G_ESC_CS(1),             /* enable chip */
73
+  0x010,		/* set upper 4 bit of the col adr to 0 */
74
+  0x000,		/* set lower 4 bit of the col adr to 0 */      
75
+  U8G_ESC_END                /* end of sequence */
76
+};
77
+
78
+static const uint8_t u8g_dev_st7565_dogm128_sleep_on[] PROGMEM = {
79
+  U8G_ESC_ADR(0),           /* instruction mode */
80
+  U8G_ESC_CS(1),             /* enable chip */
81
+  0x0ac,		/* static indicator off */
82
+  0x000,		                /* indicator register set (not sure if this is required) */
83
+  0x0ae,		/* display off */      
84
+  0x0a5,		/* all points on */      
85
+  U8G_ESC_CS(1),             /* disable chip */
86
+  U8G_ESC_END                /* end of sequence */
87
+};
88
+
89
+static const uint8_t u8g_dev_st7565_dogm128_sleep_off[] PROGMEM = {
90
+  U8G_ESC_ADR(0),           /* instruction mode */
91
+  U8G_ESC_CS(1),             /* enable chip */
92
+  0x0a4,		/* all points off */      
93
+  0x0af,		/* display on */      
94
+  U8G_ESC_DLY(50),       /* delay 50 ms */
95
+  U8G_ESC_CS(1),             /* disable chip */
96
+  U8G_ESC_END                /* end of sequence */
97
+};
98
+
99
+uint8_t u8g_dev_st7565_dogm128_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
100
+{
101
+  switch(msg)
102
+  {
103
+    case U8G_DEV_MSG_INIT:
104
+      u8g_InitCom(u8g, dev);
105
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm128_init_seq);
106
+      break;
107
+    case U8G_DEV_MSG_STOP:
108
+      break;
109
+    case U8G_DEV_MSG_PAGE_NEXT:
110
+      {
111
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
112
+        u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm128_data_start);    
113
+        u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
114
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
115
+        if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
116
+          return 0;
117
+        u8g_SetChipSelect(u8g, dev, 0);
118
+      }
119
+      break;
120
+    case U8G_DEV_MSG_CONTRAST:
121
+      u8g_SetChipSelect(u8g, dev, 1);
122
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
123
+      u8g_WriteByte(u8g, dev, 0x081);
124
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
125
+      u8g_SetChipSelect(u8g, dev, 0);      
126
+      return 1;
127
+    case U8G_DEV_MSG_SLEEP_ON:
128
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm128_sleep_on);    
129
+      return 1;
130
+    case U8G_DEV_MSG_SLEEP_OFF:
131
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm128_sleep_off);    
132
+      return 1;
133
+  }
134
+  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
135
+}
136
+
137
+U8G_PB_DEV(u8g_dev_st7565_dogm128_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_dogm128_fn, U8G_COM_SW_SPI);
138
+U8G_PB_DEV(u8g_dev_st7565_dogm128_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_dogm128_fn, U8G_COM_HW_SPI);
139
+
140
+

+ 157
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7565_dogm132.c View File

@@ -0,0 +1,157 @@
1
+/*
2
+
3
+  u8g_dev_st7565_dogm132.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+  
35
+*/
36
+
37
+#include "u8g.h"
38
+
39
+#define WIDTH 132
40
+#define HEIGHT 32
41
+#define PAGE_HEIGHT 8
42
+
43
+static const uint8_t u8g_dev_st7565_dogm132_init_seq[] PROGMEM = {
44
+  U8G_ESC_CS(0),             /* disable chip */
45
+  U8G_ESC_ADR(0),           /* instruction mode */
46
+  U8G_ESC_RST(1),           /* do reset low pulse with (1*16)+2 milliseconds */
47
+  U8G_ESC_CS(1),             /* enable chip */
48
+
49
+  0x040,		/* set display start line to 0 */
50
+  0x0a1,		/* ADC set to reverse */
51
+  0x0c0,		/* common output mode */
52
+  0x0a6,		/* display normal, bit val 0: LCD pixel off. */
53
+  0x0a2,		/* LCD bias 1/9 */
54
+  0x02f,		/* all power  control circuits on */
55
+  0x0f8,		/* set booster ratio to */
56
+  0x000,		/* 4x */
57
+  0x023,		/* set V0 voltage resistor ratio to large */
58
+  0x081,		/* set contrast */
59
+  0x01f,		/* contrast value, EA default: 0x01f */
60
+  0x0ac,		/* indicator */
61
+  0x000,		/* disable */
62
+  0x0af,		/* display on */
63
+
64
+#ifdef OBSOLETE_DOGM128  
65
+  0x040,		                /* set display start line */
66
+  0x0c8,		                /* set scan direction inverse operation */
67
+  0x0a2,		                /* LCD bias 1/9 */
68
+  0x02f,		                /* all power  control circuits on */
69
+  0x0f8,		                /* set booster ratio to */
70
+  0x000,		                /* 4x */
71
+  0x027,		                /* set V0 voltage resistor ratio to large */
72
+  0x081,		                /* set contrast */
73
+  0x018,		                /* contrast value, EA default: 0x016 */
74
+  0x0ac,		                /* indicator */
75
+  0x000,		                /* disable */
76
+  0x0af,		                /* display on */
77
+#endif
78
+
79
+
80
+  U8G_ESC_DLY(100),       /* delay 100 ms */
81
+  0x0a5,		                /* display all points, ST7565 */
82
+  U8G_ESC_DLY(100),       /* delay 100 ms */
83
+  U8G_ESC_DLY(100),       /* delay 100 ms */
84
+  0x0a4,		                /* normal display */
85
+  U8G_ESC_CS(0),             /* disable chip */
86
+  U8G_ESC_END                /* end of sequence */
87
+};
88
+
89
+static const uint8_t u8g_dev_st7565_dogm132_data_start[] PROGMEM = {
90
+  U8G_ESC_ADR(0),           /* instruction mode */
91
+  U8G_ESC_CS(1),             /* enable chip */
92
+  0x010,		/* set upper 4 bit of the col adr to 0 */
93
+  0x000,		/* set lower 4 bit of the col adr to 0  */
94
+  U8G_ESC_END                /* end of sequence */
95
+};
96
+
97
+static const uint8_t u8g_dev_st7565_dogm132_sleep_on[] PROGMEM = {
98
+  U8G_ESC_ADR(0),           /* instruction mode */
99
+  U8G_ESC_CS(1),             /* enable chip */
100
+  0x0ac,		/* static indicator off */
101
+  0x000,		                /* indicator register set (not sure if this is required) */
102
+  0x0ae,		/* display off */      
103
+  0x0a5,		/* all points on */      
104
+  U8G_ESC_CS(1),             /* disable chip */
105
+  U8G_ESC_END                /* end of sequence */
106
+};
107
+
108
+static const uint8_t u8g_dev_st7565_dogm132_sleep_off[] PROGMEM = {
109
+  U8G_ESC_ADR(0),           /* instruction mode */
110
+  U8G_ESC_CS(1),             /* enable chip */
111
+  0x0a4,		/* all points off */      
112
+  0x0af,		/* display on */      
113
+  U8G_ESC_DLY(50),       /* delay 50 ms */
114
+  U8G_ESC_CS(1),             /* disable chip */
115
+  U8G_ESC_END                /* end of sequence */
116
+};
117
+
118
+uint8_t u8g_dev_st7565_dogm132_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
119
+{
120
+  switch(msg)
121
+  {
122
+    case U8G_DEV_MSG_INIT:
123
+      u8g_InitCom(u8g, dev);
124
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm132_init_seq);
125
+      break;
126
+    case U8G_DEV_MSG_STOP:
127
+      break;
128
+    case U8G_DEV_MSG_PAGE_NEXT:
129
+      {
130
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
131
+        u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm132_data_start);    
132
+        u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
133
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
134
+        if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
135
+          return 0;
136
+        u8g_SetChipSelect(u8g, dev, 0);
137
+      }
138
+      break;
139
+    case U8G_DEV_MSG_CONTRAST:
140
+      u8g_SetChipSelect(u8g, dev, 1);
141
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
142
+      u8g_WriteByte(u8g, dev, 0x081);
143
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
144
+      u8g_SetChipSelect(u8g, dev, 0);      
145
+      return 1;
146
+    case U8G_DEV_MSG_SLEEP_ON:
147
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm132_sleep_on);    
148
+      return 1;
149
+    case U8G_DEV_MSG_SLEEP_OFF:
150
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_dogm132_sleep_off);    
151
+      return 1;
152
+  }
153
+  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
154
+}
155
+
156
+U8G_PB_DEV(u8g_dev_st7565_dogm132_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_dogm132_fn, U8G_COM_SW_SPI);
157
+U8G_PB_DEV(u8g_dev_st7565_dogm132_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_dogm132_fn, U8G_COM_HW_SPI);

+ 157
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7565_lm6059.c View File

@@ -0,0 +1,157 @@
1
+/*
2
+
3
+  u8g_dev_st7565_lm6059.c (Adafruit display)
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+  
35
+*/
36
+
37
+#include "u8g.h"
38
+
39
+#define WIDTH 128
40
+#define HEIGHT 64
41
+#define PAGE_HEIGHT 8
42
+
43
+/* init sequence from https://github.com/adafruit/ST7565-LCD/blob/master/ST7565/ST7565.cpp */
44
+static const uint8_t u8g_dev_st7565_lm6059_init_seq[] PROGMEM = {
45
+  U8G_ESC_CS(0),             /* disable chip */
46
+  U8G_ESC_ADR(0),           /* instruction mode */
47
+  U8G_ESC_CS(1),             /* enable chip */
48
+  U8G_ESC_RST(15),           /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
49
+
50
+  0x0a3,		                /* 0x0a2: LCD bias 1/9 (suggested for the LM6063), 0x0a3: Used by Adafruit, 0x0a2 does not work */
51
+  /* the LM6059 vs LM6063, ADC and SHL have inverted settings */
52
+  0x0a0,		                /* 0x0a1: ADC set to normal (suggested for the LM6059), 0x0a0: Used by Adafruit -> normal mode */
53
+  0x0c8,                            /* common output mode: set scan direction normal operation/SHL Select, 0x0c0 --> SHL = 0, normal, 0x0c8 --> SHL = 1 */
54
+  0x060,		                /* set display start line */
55
+  
56
+  0x028 | 0x04,                 /* power control: turn on voltage converter */
57
+  U8G_ESC_DLY(50),         /* delay 50 ms */
58
+
59
+  0x028 | 0x06,                 /* power control: turn on voltage regulator */
60
+  U8G_ESC_DLY(50),         /* delay 50 ms */
61
+  
62
+  0x028 | 0x07,                 /* power control: turn on voltage follower */
63
+  U8G_ESC_DLY(50),         /* delay 50 ms */
64
+
65
+  0x026,		                /* set V0 voltage resistor ratio to 6 (Adafruit Value, no info from LM6063 Manual) */
66
+  
67
+  0x0a6,                           /* display normal, bit val 0: LCD pixel off. */
68
+  
69
+  0x081,		                /* set contrast */
70
+  0x018,		                /* contrast value*/
71
+  
72
+  /*0x0ac,*/		                /* indicator */
73
+  /*0x000,*/		                /* disable */
74
+  
75
+  0x0af,		                /* display on */
76
+
77
+  U8G_ESC_DLY(100),       /* delay 100 ms */
78
+  0x0a5,		                /* display all points, ST7565 */
79
+  U8G_ESC_DLY(100),       /* delay 100 ms */
80
+  U8G_ESC_DLY(100),       /* delay 100 ms */
81
+  0x0a4,		                /* normal display */
82
+  U8G_ESC_CS(0),             /* disable chip */
83
+  U8G_ESC_END                /* end of sequence */
84
+};
85
+
86
+static const uint8_t u8g_dev_st7565_lm6059_data_start[] PROGMEM = {
87
+  U8G_ESC_ADR(0),           /* instruction mode */
88
+  U8G_ESC_CS(1),             /* enable chip */
89
+  0x010,		/* set upper 4 bit of the col adr to 0 */
90
+  0x001,		/* set lower 4 bit of the col adr  */      
91
+  U8G_ESC_END                /* end of sequence */
92
+};
93
+
94
+static const uint8_t u8g_dev_st7565_lm6059_sleep_on[] PROGMEM = {
95
+  U8G_ESC_ADR(0),           /* instruction mode */
96
+  U8G_ESC_CS(1),             /* enable chip */
97
+  0x0ac,		/* static indicator off */
98
+  0x000,		                /* indicator register set (not sure if this is required) */
99
+  0x0ae,		/* display off */      
100
+  0x0a5,		/* all points on */      
101
+  U8G_ESC_CS(1),             /* disable chip */
102
+  U8G_ESC_END                /* end of sequence */
103
+};
104
+
105
+static const uint8_t u8g_dev_st7565_lm6059_sleep_off[] PROGMEM = {
106
+  U8G_ESC_ADR(0),           /* instruction mode */
107
+  U8G_ESC_CS(1),             /* enable chip */
108
+  0x0a4,		/* all points off */      
109
+  0x0af,		/* display on */      
110
+  U8G_ESC_DLY(50),       /* delay 50 ms */
111
+  U8G_ESC_CS(1),             /* disable chip */
112
+  U8G_ESC_END                /* end of sequence */
113
+};
114
+
115
+
116
+uint8_t u8g_dev_st7565_lm6059_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
117
+{
118
+  switch(msg)
119
+  {
120
+    case U8G_DEV_MSG_INIT:
121
+      u8g_InitCom(u8g, dev);
122
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6059_init_seq);
123
+      break;
124
+    case U8G_DEV_MSG_STOP:
125
+      break;
126
+    case U8G_DEV_MSG_PAGE_NEXT:
127
+      {
128
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
129
+        u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6059_data_start);    
130
+        u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
131
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
132
+        if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
133
+          return 0;
134
+        u8g_SetChipSelect(u8g, dev, 0);
135
+      }
136
+      break;
137
+    case U8G_DEV_MSG_CONTRAST:
138
+      u8g_SetChipSelect(u8g, dev, 1);
139
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
140
+      u8g_WriteByte(u8g, dev, 0x081);
141
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
142
+      u8g_SetChipSelect(u8g, dev, 0);      
143
+      return 1;
144
+    case U8G_DEV_MSG_SLEEP_ON:
145
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6059_sleep_on);    
146
+      return 1;
147
+    case U8G_DEV_MSG_SLEEP_OFF:
148
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6059_sleep_off);    
149
+      return 1;
150
+  }
151
+  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
152
+}
153
+
154
+U8G_PB_DEV(u8g_dev_st7565_lm6059_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_lm6059_fn, U8G_COM_SW_SPI);
155
+U8G_PB_DEV(u8g_dev_st7565_lm6059_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_lm6059_fn, U8G_COM_HW_SPI);
156
+
157
+

+ 188
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7565_lm6063.c View File

@@ -0,0 +1,188 @@
1
+/*
2
+
3
+  u8g_dev_st7565_lm6063.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+  
35
+*/
36
+
37
+#include "u8g.h"
38
+
39
+#define WIDTH 128
40
+#define HEIGHT 64
41
+#define PAGE_HEIGHT 8
42
+
43
+#ifdef OLD_ADAFRUIT_CODE
44
+static const uint8_t OLD_u8g_dev_st7565_lm6063_init_seq[] PROGMEM = {
45
+  U8G_ESC_CS(0),             /* disable chip */
46
+  U8G_ESC_ADR(0),           /* instruction mode */
47
+  U8G_ESC_RST(1),           /* do reset low pulse with (1*16)+2 milliseconds */
48
+  U8G_ESC_CS(1),             /* enable chip */
49
+  
50
+  0x040,		                /* set display start line */
51
+  0x0a1,		                /* ADC set to reverse */
52
+  0x0c8,		                /* common output mode: set scan direction normal operation/SHL Select / 17 Jan: seems to be a bug, must be 0x0c0 */
53
+  0x0a6,                           /* display normal, bit val 0: LCD pixel off. */
54
+  0x0a2,		                /* LCD bias 1/9 */
55
+  0x02f,		                /* all power  control circuits on */
56
+  /*0x0f8,*/		                /* set booster ratio to */
57
+  /*0x000,	*/	                /* 4x */
58
+  /*0x027,*/		                /* set V0 voltage resistor ratio to large */
59
+  0x081,		                /* set contrast */
60
+  0x018,		                /* contrast value*/
61
+  0x0ac,		                /* indicator */
62
+  0x000,		                /* disable */
63
+  0x0af,		                /* display on */
64
+
65
+  U8G_ESC_DLY(100),       /* delay 100 ms */
66
+  0x0a5,		                /* display all points, ST7565 */
67
+  U8G_ESC_DLY(100),       /* delay 100 ms */
68
+  U8G_ESC_DLY(100),       /* delay 100 ms */
69
+  0x0a4,		                /* normal display */
70
+  U8G_ESC_CS(0),             /* disable chip */
71
+  U8G_ESC_END                /* end of sequence */
72
+};
73
+#endif
74
+
75
+/* init sequence from https://github.com/adafruit/ST7565-LCD/blob/master/ST7565/ST7565.cpp */
76
+static const uint8_t u8g_dev_st7565_lm6063_init_seq[] PROGMEM = {
77
+  U8G_ESC_CS(0),             /* disable chip */
78
+  U8G_ESC_ADR(0),           /* instruction mode */
79
+  U8G_ESC_CS(1),             /* enable chip */
80
+  U8G_ESC_RST(15),           /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
81
+
82
+  0x0a3,		                /* 0x0a2: LCD bias 1/9 (suggested for the LM6063), 0x0a3: Used by Adafruit */
83
+  0x0a1,		                /* 0x0a1: ADC set to reverse (suggested for the LM6063), 0x0a0: Used by Adafruit -> normal mode */
84
+  0x0c0,                            /* common output mode: set scan direction normal operation/SHL Select, 0x0c0 --> SHL = 0, normal, 0x0c8 --> SHL = 1 */
85
+  0x040,		                /* set display start line */
86
+  
87
+  0x028 | 0x04,                 /* power control: turn on voltage converter */
88
+  U8G_ESC_DLY(50),         /* delay 50 ms */
89
+
90
+  0x028 | 0x06,                 /* power control: turn on voltage regulator */
91
+  U8G_ESC_DLY(50),         /* delay 50 ms */
92
+  
93
+  0x028 | 0x07,                 /* power control: turn on voltage follower */
94
+  U8G_ESC_DLY(50),         /* delay 50 ms */
95
+
96
+  0x026,		                /* set V0 voltage resistor ratio to 6 (Adafruit Value, no info from LM6063 Manual) */
97
+  
98
+  0x0a6,                           /* display normal, bit val 0: LCD pixel off. */
99
+  
100
+  0x081,		                /* set contrast */
101
+  0x018,		                /* contrast value*/
102
+  
103
+  /*0x0ac,*/		                /* indicator */
104
+  /*0x000,*/		                /* disable */
105
+  
106
+  0x0af,		                /* display on */
107
+
108
+  U8G_ESC_DLY(100),       /* delay 100 ms */
109
+  0x0a5,		                /* display all points, ST7565 */
110
+  U8G_ESC_DLY(100),       /* delay 100 ms */
111
+  U8G_ESC_DLY(100),       /* delay 100 ms */
112
+  0x0a4,		                /* normal display */
113
+  U8G_ESC_CS(0),             /* disable chip */
114
+  U8G_ESC_END                /* end of sequence */
115
+};
116
+
117
+static const uint8_t u8g_dev_st7565_lm6063_data_start[] PROGMEM = {
118
+  U8G_ESC_ADR(0),           /* instruction mode */
119
+  U8G_ESC_CS(1),             /* enable chip */
120
+  0x010,		/* set upper 4 bit of the col adr to 0 */
121
+  0x000,		/* set lower 4 bit of the col adr to 0 */      
122
+  U8G_ESC_END                /* end of sequence */
123
+};
124
+
125
+static const uint8_t u8g_dev_st7565_st7565_sleep_on[] PROGMEM = {
126
+  U8G_ESC_ADR(0),           /* instruction mode */
127
+  U8G_ESC_CS(1),             /* enable chip */
128
+  0x0ac,		/* static indicator off */
129
+  0x000,		                /* indicator register set (not sure if this is required) */
130
+  0x0ae,		/* display off */      
131
+  0x0a5,		/* all points on */      
132
+  U8G_ESC_CS(1),             /* disable chip */
133
+  U8G_ESC_END                /* end of sequence */
134
+};
135
+
136
+static const uint8_t u8g_dev_st7565_st7565_sleep_off[] PROGMEM = {
137
+  U8G_ESC_ADR(0),           /* instruction mode */
138
+  U8G_ESC_CS(1),             /* enable chip */
139
+  0x0a4,		/* all points off */      
140
+  0x0af,		/* display on */      
141
+  U8G_ESC_DLY(50),       /* delay 50 ms */
142
+  U8G_ESC_CS(1),             /* disable chip */
143
+  U8G_ESC_END                /* end of sequence */
144
+};
145
+
146
+
147
+uint8_t u8g_dev_st7565_lm6063_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
148
+{
149
+  switch(msg)
150
+  {
151
+    case U8G_DEV_MSG_INIT:
152
+      u8g_InitCom(u8g, dev);
153
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6063_init_seq);
154
+      break;
155
+    case U8G_DEV_MSG_STOP:
156
+      break;
157
+    case U8G_DEV_MSG_PAGE_NEXT:
158
+      {
159
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
160
+        u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_lm6063_data_start);    
161
+        u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
162
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
163
+        if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
164
+          return 0;
165
+        u8g_SetChipSelect(u8g, dev, 0);
166
+      }
167
+      break;
168
+    case U8G_DEV_MSG_CONTRAST:
169
+      u8g_SetChipSelect(u8g, dev, 1);
170
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
171
+      u8g_WriteByte(u8g, dev, 0x081);
172
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
173
+      u8g_SetChipSelect(u8g, dev, 0);      
174
+      return 1;
175
+    case U8G_DEV_MSG_SLEEP_ON:
176
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_st7565_sleep_on);    
177
+      return 1;
178
+    case U8G_DEV_MSG_SLEEP_OFF:
179
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_st7565_sleep_off);    
180
+      return 1;
181
+  }
182
+  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
183
+}
184
+
185
+U8G_PB_DEV(u8g_dev_st7565_lm6063_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_lm6063_fn, U8G_COM_SW_SPI);
186
+U8G_PB_DEV(u8g_dev_st7565_lm6063_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_lm6063_fn, U8G_COM_HW_SPI);
187
+
188
+

+ 143
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7565_nhd_c12832.c View File

@@ -0,0 +1,143 @@
1
+/*
2
+
3
+  u8g_dev_st7565_nhd_c12832.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+  
35
+*/
36
+
37
+#include "u8g.h"
38
+
39
+#define WIDTH 128
40
+#define HEIGHT 32
41
+#define PAGE_HEIGHT 8
42
+
43
+static const uint8_t u8g_dev_st7565_c12832_init_seq[] PROGMEM = {
44
+  U8G_ESC_CS(0),             /* disable chip */
45
+  U8G_ESC_ADR(0),           /* instruction mode */
46
+  U8G_ESC_RST(1),           /* do reset low pulse with (1*16)+2 milliseconds */
47
+  U8G_ESC_CS(1),             /* enable chip */
48
+
49
+  0x040,		/* set display start line to 0 */
50
+  0x0a0,		/* ADC set, values: a0=normal, a1=reverse */
51
+  0x0c8,		/* common output mode: c0=normal, c8=reverse */
52
+  0x0a6,		/* display normal, bit val 0: LCD pixel off. */
53
+  0x0a2,		/* LCD bias 1/9 */
54
+  0x02f,		/* all power  control circuits on */
55
+  0x0f8,		/* set booster ratio to */
56
+  0x000,		/* 4x */
57
+  0x023,		/* set V0 voltage resistor ratio to large */
58
+  0x081,		/* set contrast */
59
+  0x00a,		/* contrast value */
60
+  0x0ac,		/* indicator */
61
+  0x000,		/* disable */
62
+  0x0af,		/* display on */
63
+
64
+
65
+  U8G_ESC_DLY(100),       /* delay 100 ms */
66
+  0x0a5,		                /* display all points, ST7565 */
67
+  U8G_ESC_DLY(100),       /* delay 100 ms */
68
+  U8G_ESC_DLY(100),       /* delay 100 ms */
69
+  0x0a4,		                /* normal display */
70
+  U8G_ESC_CS(0),             /* disable chip */
71
+  U8G_ESC_END                /* end of sequence */
72
+};
73
+
74
+static const uint8_t u8g_dev_st7565_c12832_data_start[] PROGMEM = {
75
+  U8G_ESC_ADR(0),           /* instruction mode */
76
+  U8G_ESC_CS(1),             /* enable chip */
77
+  0x010,		/* set upper 4 bit of the col adr to 0 */
78
+  0x000,		/* set lower 4 bit of the col adr to 0  */
79
+  U8G_ESC_END                /* end of sequence */
80
+};
81
+
82
+static const uint8_t u8g_dev_st7565_c12832_sleep_on[] PROGMEM = {
83
+  U8G_ESC_ADR(0),           /* instruction mode */
84
+  U8G_ESC_CS(1),             /* enable chip */
85
+  0x0ac,		/* static indicator off */
86
+  0x000,		                /* indicator register set (not sure if this is required) */
87
+  0x0ae,		/* display off */      
88
+  0x0a5,		/* all points on */      
89
+  U8G_ESC_CS(1),             /* disable chip */
90
+  U8G_ESC_END                /* end of sequence */
91
+};
92
+
93
+static const uint8_t u8g_dev_st7565_c12832_sleep_off[] PROGMEM = {
94
+  U8G_ESC_ADR(0),           /* instruction mode */
95
+  U8G_ESC_CS(1),             /* enable chip */
96
+  0x0a4,		/* all points off */      
97
+  0x0af,		/* display on */      
98
+  U8G_ESC_DLY(50),       /* delay 50 ms */
99
+  U8G_ESC_CS(1),             /* disable chip */
100
+  U8G_ESC_END                /* end of sequence */
101
+};
102
+
103
+uint8_t u8g_dev_st7565_c12832_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
104
+{
105
+  switch(msg)
106
+  {
107
+    case U8G_DEV_MSG_INIT:
108
+      u8g_InitCom(u8g, dev);
109
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_c12832_init_seq);
110
+      break;
111
+    case U8G_DEV_MSG_STOP:
112
+      break;
113
+    case U8G_DEV_MSG_PAGE_NEXT:
114
+      {
115
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
116
+        u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_c12832_data_start);    
117
+        u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
118
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
119
+        if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
120
+          return 0;
121
+        u8g_SetChipSelect(u8g, dev, 0);
122
+      }
123
+      break;
124
+    case U8G_DEV_MSG_CONTRAST:
125
+      u8g_SetChipSelect(u8g, dev, 1);
126
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
127
+      u8g_WriteByte(u8g, dev, 0x081);
128
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
129
+      u8g_SetChipSelect(u8g, dev, 0);      
130
+      return 1;
131
+    case U8G_DEV_MSG_SLEEP_ON:
132
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_c12832_sleep_on);    
133
+      return 1;
134
+    case U8G_DEV_MSG_SLEEP_OFF:
135
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_c12832_sleep_off);    
136
+      return 1;
137
+  }
138
+  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
139
+}
140
+
141
+U8G_PB_DEV(u8g_dev_st7565_nhd_c12832_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_c12832_fn, U8G_COM_SW_SPI);
142
+U8G_PB_DEV(u8g_dev_st7565_nhd_c12832_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_c12832_fn, U8G_COM_HW_SPI);
143
+U8G_PB_DEV(u8g_dev_st7565_nhd_c12832_parallel, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_c12832_fn, U8G_COM_PARALLEL);

+ 145
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7565_nhd_c12864.c View File

@@ -0,0 +1,145 @@
1
+/*
2
+
3
+  u8g_dev_st7565_nhd_c12864.c
4
+
5
+  Support for the NHD-C12864A1Z-FSB-FBW (Newhaven Display)
6
+
7
+  Universal 8bit Graphics Library
8
+  
9
+  Copyright (c) 2012, olikraus@gmail.com
10
+  All rights reserved.
11
+
12
+  Redistribution and use in source and binary forms, with or without modification, 
13
+  are permitted provided that the following conditions are met:
14
+
15
+  * Redistributions of source code must retain the above copyright notice, this list 
16
+    of conditions and the following disclaimer.
17
+    
18
+  * Redistributions in binary form must reproduce the above copyright notice, this 
19
+    list of conditions and the following disclaimer in the documentation and/or other 
20
+    materials provided with the distribution.
21
+
22
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
23
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
24
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
25
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
26
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
27
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
28
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
29
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
30
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
31
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
32
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
33
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
34
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
35
+  
36
+  
37
+*/
38
+
39
+#include "u8g.h"
40
+
41
+#define WIDTH 128
42
+#define HEIGHT 64
43
+#define PAGE_HEIGHT 8
44
+
45
+const uint8_t u8g_dev_st7565_nhd_c12864_init_seq[] PROGMEM = {
46
+  U8G_ESC_CS(0),             /* disable chip */
47
+  U8G_ESC_ADR(0),           /* instruction mode */
48
+  U8G_ESC_RST(10),           /* do reset low pulse with (10*16)+2 milliseconds */
49
+  U8G_ESC_CS(1),             /* enable chip */
50
+  
51
+  0x040,		                /* set display start line */
52
+  0x0a1,		                /* ADC set to reverse */
53
+  0x0c0,		                /* common output mode: set scan direction normal operation */
54
+  0x0a6,                           /* display normal, bit val 0: LCD pixel off. */
55
+  0x0a2,		                /* LCD bias 1/9 */
56
+  0x02f,		                /* all power  control circuits on */
57
+  0x0f8,		                /* set booster ratio to */
58
+  0x000,		                /* 4x */
59
+  0x027,		                /* set V0 voltage resistor ratio to large */
60
+  0x081,		                /* set contrast */
61
+  0x008,		                /* contrast: 0x008 is a good value for NHD C12864, Nov 2012: User reports that 0x1a is much better */
62
+  0x0ac,		                /* indicator */
63
+  0x000,		                /* disable */
64
+  0x0af,		                /* display on */
65
+
66
+  U8G_ESC_DLY(100),       /* delay 100 ms */
67
+  0x0a5,		                /* display all points, ST7565 */
68
+  U8G_ESC_DLY(100),       /* delay 100 ms */
69
+  U8G_ESC_DLY(100),       /* delay 100 ms */
70
+  0x0a4,		                /* normal display */
71
+  U8G_ESC_CS(0),             /* disable chip */
72
+  U8G_ESC_END                /* end of sequence */
73
+};
74
+
75
+static const uint8_t u8g_dev_st7565_nhd_c12864_data_start[] PROGMEM = {
76
+  U8G_ESC_ADR(0),           /* instruction mode */
77
+  U8G_ESC_CS(1),             /* enable chip */
78
+  0x010,		/* set upper 4 bit of the col adr to 0 */
79
+  0x004,		/* set lower 4 bit of the col adr to 4 (NHD C12864) */  
80
+  U8G_ESC_END                /* end of sequence */
81
+};
82
+
83
+static const uint8_t u8g_dev_st7565_c12864_sleep_on[] PROGMEM = {
84
+  U8G_ESC_ADR(0),           /* instruction mode */
85
+  U8G_ESC_CS(1),             /* enable chip */
86
+  0x0ac,		/* static indicator off */
87
+  0x000,		                /* indicator register set (not sure if this is required) */
88
+  0x0ae,		/* display off */      
89
+  0x0a5,		/* all points on */      
90
+  U8G_ESC_CS(1),             /* disable chip */
91
+  U8G_ESC_END                /* end of sequence */
92
+};
93
+
94
+static const uint8_t u8g_dev_st7565_c12864_sleep_off[] PROGMEM = {
95
+  U8G_ESC_ADR(0),           /* instruction mode */
96
+  U8G_ESC_CS(1),             /* enable chip */
97
+  0x0a4,		/* all points off */      
98
+  0x0af,		/* display on */      
99
+  U8G_ESC_DLY(50),       /* delay 50 ms */
100
+  U8G_ESC_CS(1),             /* disable chip */
101
+  U8G_ESC_END                /* end of sequence */
102
+};
103
+
104
+uint8_t u8g_dev_st7565_nhd_c12864_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
105
+{
106
+  switch(msg)
107
+  {
108
+    case U8G_DEV_MSG_INIT:
109
+      u8g_InitCom(u8g, dev);
110
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_nhd_c12864_init_seq);
111
+      break;
112
+    case U8G_DEV_MSG_STOP:
113
+      break;
114
+    case U8G_DEV_MSG_PAGE_NEXT:
115
+      {
116
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
117
+        u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_nhd_c12864_data_start);    
118
+        u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
119
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
120
+        if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
121
+          return 0;
122
+        u8g_SetChipSelect(u8g, dev, 0);
123
+      }
124
+      break;
125
+    case U8G_DEV_MSG_CONTRAST:
126
+      u8g_SetChipSelect(u8g, dev, 1);
127
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
128
+      u8g_WriteByte(u8g, dev, 0x081);
129
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
130
+      u8g_SetChipSelect(u8g, dev, 0);      
131
+      return 1;
132
+    case U8G_DEV_MSG_SLEEP_ON:
133
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_c12864_sleep_on);    
134
+      return 1;
135
+    case U8G_DEV_MSG_SLEEP_OFF:
136
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7565_c12864_sleep_off);    
137
+      return 1;
138
+  }
139
+  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
140
+}
141
+
142
+U8G_PB_DEV(u8g_dev_st7565_nhd_c12864_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_nhd_c12864_fn, U8G_COM_SW_SPI);
143
+U8G_PB_DEV(u8g_dev_st7565_nhd_c12864_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7565_nhd_c12864_fn, U8G_COM_HW_SPI);
144
+
145
+

+ 420
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7687_c144mvgd.c View File

@@ -0,0 +1,420 @@
1
+/*
2
+
3
+  u8g_dev_st7687_c144mvgd.c (1.44" TFT)
4
+  
5
+  Status: Started, but not finished
6
+
7
+  Universal 8bit Graphics Library
8
+  
9
+  Copyright (c) 2012, olikraus@gmail.com
10
+  All rights reserved.
11
+
12
+  Redistribution and use in source and binary forms, with or without modification, 
13
+  are permitted provided that the following conditions are met:
14
+
15
+  * Redistributions of source code must retain the above copyright notice, this list 
16
+    of conditions and the following disclaimer.
17
+    
18
+  * Redistributions in binary form must reproduce the above copyright notice, this 
19
+    list of conditions and the following disclaimer in the documentation and/or other 
20
+    materials provided with the distribution.
21
+
22
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
23
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
24
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
25
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
26
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
27
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
28
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
29
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
30
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
31
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
32
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
33
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
34
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
35
+  
36
+  
37
+*/
38
+
39
+#include "u8g.h"
40
+
41
+#define WIDTH 128
42
+#define HEIGHT 128
43
+#define PAGE_HEIGHT 8
44
+
45
+
46
+#ifdef FIRST_VERSION
47
+/* 
48
+see also: read.pudn.com/downloads115/sourcecode/app/484503/LCM_Display.c__.htm 
49
+http://en.pudn.com/downloads115/sourcecode/app/detail484503_en.html
50
+*/
51
+
52
+static const uint8_t u8g_dev_st7687_c144mvgd_init_seq[] PROGMEM = {
53
+  U8G_ESC_CS(0),             /* disable chip */
54
+  U8G_ESC_ADR(0),           /* instruction mode */
55
+  U8G_ESC_CS(1),             /* enable chip */
56
+  U8G_ESC_RST(15),           /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
57
+  
58
+  0x001,                        /* A0=0, SW reset */
59
+  U8G_ESC_DLY(200),         /* delay 200 ms */
60
+  
61
+  0x0d7,                        /* EEPROM data auto re-load control */
62
+  U8G_ESC_ADR(1),           /* data mode */
63
+  0x09f,                             /* ARD = 1 */
64
+  U8G_ESC_ADR(0),           /* instruction mode */
65
+  U8G_ESC_DLY(100),         /* delay 100 ms */
66
+  
67
+  0x0e0,                        /* EEPROM control in */
68
+  U8G_ESC_ADR(1),           /* data mode */
69
+  0x000,                             /*  */
70
+  U8G_ESC_ADR(0),           /* instruction mode */
71
+  U8G_ESC_DLY(100),         /* delay 100 ms */
72
+  
73
+#ifdef NOT_REQUIRED  
74
+  0x0fa,                        /* EEPROM function selection 8.1.66 */
75
+  U8G_ESC_ADR(1),           /* data mode */
76
+  0x000,                             /*  */
77
+  U8G_ESC_ADR(0),           /* instruction mode */
78
+  U8G_ESC_DLY(100),         /* delay 100 ms */
79
+#endif 
80
+
81
+  0x0e3,                        /* Read from EEPROM, 8.1.55 */
82
+  U8G_ESC_DLY(100),         /* delay 100 ms */
83
+
84
+  0x0e1,                        /* EEPROM control out, 8.1.53 */
85
+  U8G_ESC_DLY(100),         /* delay 100 ms */
86
+  
87
+  //0x028,                        /* display off */
88
+  0x011,                                /* Sleep out & booster on */
89
+  U8G_ESC_DLY(100),         /* delay 100 ms */
90
+  
91
+  0x0c0,                        /* Vop setting, 8.1.42 */
92
+  U8G_ESC_ADR(1),           /* data mode */
93
+  0x000,                             /*  */
94
+  0x001,                             /*  3.6 + 256*0.04 = 13.84 Volt */
95
+  U8G_ESC_ADR(0),           /* instruction mode */
96
+  U8G_ESC_DLY(100),         /* delay 100 ms */
97
+  
98
+  0x0c3,                                /* Bias selection, 8.1.45 */
99
+  U8G_ESC_ADR(1),           /* data mode */
100
+  0x003,
101
+  U8G_ESC_ADR(0),           /* instruction mode */
102
+  
103
+  0x0c4,                                /* Booster setting 8.1.46 */
104
+  U8G_ESC_ADR(1),           /* data mode */
105
+  0x007,
106
+  U8G_ESC_ADR(0),           /* instruction mode */
107
+  
108
+  0x0c5,                                /* ??? */
109
+  U8G_ESC_ADR(1),           /* data mode */
110
+  0x001,
111
+  U8G_ESC_ADR(0),           /* instruction mode */
112
+  
113
+  0x0cb,                                /* FV3 with Booster x2 control, 8.1.47 */
114
+  U8G_ESC_ADR(1),           /* data mode */
115
+  0x001,
116
+  U8G_ESC_ADR(0),           /* instruction mode */
117
+  
118
+  0x036,                                /* Memory data access control, 8.1.28 */
119
+  U8G_ESC_ADR(1),           /* data mode */
120
+  0x080,
121
+  U8G_ESC_ADR(0),           /* instruction mode */
122
+
123
+  0x0b5,                                /* N-line control, 8.1.37 */
124
+  U8G_ESC_ADR(1),           /* data mode */
125
+  0x089,
126
+  U8G_ESC_ADR(0),           /* instruction mode */
127
+
128
+
129
+  0x0d0,                                /* Analog circuit setting, 8.1.49 */
130
+  U8G_ESC_ADR(1),           /* data mode */
131
+  0x01d,
132
+  U8G_ESC_ADR(0),           /* instruction mode */
133
+
134
+  0x0b7,                                /* Com/Seg Scan Direction, 8.1.38 */
135
+  U8G_ESC_ADR(1),           /* data mode */
136
+  0x040,
137
+  U8G_ESC_ADR(0),           /* instruction mode */
138
+
139
+  0x025,                                /* Write contrast, 8.1.17 */
140
+  U8G_ESC_ADR(1),           /* data mode */
141
+  0x03f,
142
+  U8G_ESC_ADR(0),           /* instruction mode */
143
+
144
+  0x03a,                                /* Interface pixel format, 8.1.32 */
145
+  U8G_ESC_ADR(1),           /* data mode */
146
+  0x004,                                /* 3: 12 bit per pixel Type A, 4: 12 bit Type B, 5: 16bit per pixel */
147
+  U8G_ESC_ADR(0),           /* instruction mode */
148
+
149
+  0x0b0,                                /* Display Duty setting, 8.1.34 */
150
+  U8G_ESC_ADR(1),           /* data mode */
151
+  0x07f,
152
+  U8G_ESC_ADR(0),           /* instruction mode */
153
+
154
+  0x0f0,                                /* Frame Freq. in Temp range A,B,C and D, 8.1.59 */
155
+  U8G_ESC_ADR(1),           /* data mode */
156
+  0x007,
157
+  0x00c,
158
+  0x00c,
159
+  0x015,
160
+  U8G_ESC_ADR(0),           /* instruction mode */
161
+
162
+  0x0f9,                                /* Frame RGB Value, 8.1.65 */
163
+  U8G_ESC_ADR(1),           /* data mode */
164
+  0x000,
165
+  0x005,
166
+  0x008,
167
+  0x00a,
168
+  0x00c,
169
+  0x00e,
170
+  0x010,
171
+  0x011,
172
+  0x012,
173
+  0x013,
174
+  0x014,
175
+  0x015,
176
+  0x016,
177
+  0x018,
178
+  0x01a,
179
+  0x01b,
180
+  U8G_ESC_ADR(0),           /* instruction mode */
181
+
182
+  0x0f9,                                /* Frame RGB Value, 8.1.65 */
183
+  U8G_ESC_ADR(1),           /* data mode */
184
+  0x000,
185
+  0x000,
186
+  0x000,
187
+  0x000,
188
+  0x033,
189
+  0x055,
190
+  0x055,
191
+  0x055,
192
+  U8G_ESC_ADR(0),           /* instruction mode */
193
+
194
+  0x029,                        /* display on */
195
+
196
+  U8G_ESC_CS(0),             /* disable chip */
197
+  U8G_ESC_END                /* end of sequence */
198
+
199
+};
200
+
201
+#else
202
+
203
+/*
204
+http://www.waitingforfriday.com/images/e/e3/FTM144D01N_test.zip
205
+*/
206
+
207
+static const uint8_t u8g_dev_st7687_c144mvgd_init_seq[] PROGMEM = {
208
+  U8G_ESC_CS(0),             /* disable chip */
209
+  U8G_ESC_ADR(0),           /* instruction mode */
210
+  U8G_ESC_CS(1),             /* enable chip */
211
+  U8G_ESC_RST(15),           /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
212
+
213
+  0x011,                                /* Sleep out & booster on */
214
+  U8G_ESC_DLY(5),         /* delay 5 ms */
215
+    
216
+  0x03a,                                /* Interface pixel format, 8.1.32 */
217
+  U8G_ESC_ADR(1),           /* data mode */
218
+  0x004,                                /* 3: 12 bit per pixel Type A, 4: 12 bit Type B, 5: 16bit per pixel */
219
+  U8G_ESC_ADR(0),           /* instruction mode */
220
+  
221
+  
222
+  0x026,                                /* SET_GAMMA_CURVE */
223
+  U8G_ESC_ADR(1),           /* data mode */
224
+  0x004,                                
225
+  U8G_ESC_ADR(0),           /* instruction mode */
226
+
227
+  0x0f2,                                /* GAM_R_SEL */
228
+  U8G_ESC_ADR(1),           /* data mode */
229
+  0x001,                                /* enable gamma adj */                                
230
+  U8G_ESC_ADR(0),           /* instruction mode */
231
+
232
+
233
+  0x0e0,                                /* POSITIVE_GAMMA_CORRECT */
234
+  U8G_ESC_ADR(1),           /* data mode */
235
+  0x3f,
236
+    0x25,
237
+    0x1c,
238
+    0x1e,
239
+    0x20,
240
+    0x12,
241
+    0x2a,
242
+    0x90,
243
+    0x24,
244
+    0x11,
245
+    0x00,
246
+    0x00,
247
+    0x00,
248
+    0x00,
249
+    0x00,    
250
+  U8G_ESC_ADR(0),           /* instruction mode */
251
+
252
+  0x0e1,                                /* NEGATIVE_GAMMA_CORRECT */
253
+  U8G_ESC_ADR(1),           /* data mode */
254
+    0x20,
255
+    0x20,
256
+    0x20,
257
+    0x20,
258
+    0x05,
259
+    0x00,
260
+    0x15,
261
+    0xa7,
262
+    0x3d,
263
+    0x18,
264
+    0x25,
265
+    0x2a,
266
+    0x2b,
267
+    0x2b,
268
+    0x3a,
269
+  U8G_ESC_ADR(0),           /* instruction mode */
270
+     
271
+  0x0b1,                                /* FRAME_RATE_CONTROL1 */
272
+  U8G_ESC_ADR(1),           /* data mode */
273
+  0x008,                                /* DIVA = 8 */
274
+  0x008,                                /* VPA = 8 */
275
+  U8G_ESC_ADR(0),           /* instruction mode */
276
+
277
+
278
+  0x0b4,                                /* DISPLAY_INVERSION */
279
+  U8G_ESC_ADR(1),           /* data mode */
280
+  0x007,                                /* NLA = 1, NLB = 1, NLC = 1 (all on Frame Inversion) */
281
+  U8G_ESC_ADR(0),           /* instruction mode */
282
+    
283
+  0x0c0,                                /* POWER_CONTROL1 */
284
+  U8G_ESC_ADR(1),           /* data mode */
285
+  0x00a,                                /* VRH = 10:  GVDD = 4.30 */
286
+  0x002,                                /* VC = 2: VCI1 = 2.65 */
287
+  U8G_ESC_ADR(0),           /* instruction mode */
288
+   
289
+  0x0c1,                                /* POWER_CONTROL2 */
290
+  U8G_ESC_ADR(1),           /* data mode */
291
+  0x002,                                /* BT = 2: AVDD = 2xVCI1, VCL = -1xVCI1, VGH = 5xVCI1, VGL = -2xVCI1 */
292
+  U8G_ESC_ADR(0),           /* instruction mode */
293
+      
294
+  0x0c5,                                /* VCOM_CONTROL1 */
295
+  U8G_ESC_ADR(1),           /* data mode */
296
+  0x050,                                /* VMH = 80: VCOMH voltage = 4.5 */
297
+  0x05b,                                /* VML = 91: VCOML voltage = -0.225 */
298
+  U8G_ESC_ADR(0),           /* instruction mode */
299
+
300
+  0x0c7,                                /* VCOM_OFFSET_CONTROL */
301
+  U8G_ESC_ADR(1),           /* data mode */
302
+  0x040,                                /* nVM = 0, VMF = 64: VCOMH output = VMH, VCOML output = VML */
303
+  U8G_ESC_ADR(0),           /* instruction mode */
304
+
305
+  0x02a,                                /* SET_COLUMN_ADDRESS */
306
+  U8G_ESC_ADR(1),           /* data mode */
307
+  0x000,                                /*  */
308
+  0x000,                                /*  */
309
+  0x000,                                /*  */
310
+  0x07f,                                /*  */
311
+  U8G_ESC_ADR(0),           /* instruction mode */
312
+
313
+  0x02b,                                /* SET_PAGE_ADDRESS */
314
+  U8G_ESC_ADR(1),           /* data mode */
315
+  0x000,                                /*  */
316
+  0x000,                                /*  */
317
+  0x000,                                /*  */
318
+  0x07f,                                /*  */
319
+  U8G_ESC_ADR(0),           /* instruction mode */
320
+
321
+  0x036,                                /* SET_ADDRESS_MODE */
322
+  U8G_ESC_ADR(1),           /* data mode */
323
+  0x000,                                /* Select display orientation */
324
+  U8G_ESC_ADR(0),           /* instruction mode */
325
+	
326
+
327
+  0x029,                        /* display on */
328
+  
329
+  0x02c,                         /* write start */
330
+  
331
+  U8G_ESC_CS(0),             /* disable chip */
332
+  U8G_ESC_END                /* end of sequence */
333
+
334
+};
335
+
336
+#endif
337
+
338
+
339
+
340
+
341
+/* calculate bytes for Type B 4096 color display */
342
+static uint8_t get_byte_1(uint8_t v)
343
+{
344
+  v >>= 4;
345
+  v &= 0x0e;
346
+  return v;
347
+}
348
+
349
+static uint8_t get_byte_2(uint8_t v)
350
+{
351
+  uint8_t w;
352
+  w = v;
353
+  w &= 3;
354
+  w = (w<<2) | w;
355
+  v <<= 3;
356
+  v &= 0x0e0;
357
+  w |= v;
358
+  return w;
359
+}
360
+
361
+uint8_t u8g_dev_st7687_c144mvgd_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
362
+{
363
+  switch(msg)
364
+  {
365
+    case U8G_DEV_MSG_INIT:
366
+      u8g_InitCom(u8g, dev);
367
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7687_c144mvgd_init_seq);
368
+      break;
369
+    case U8G_DEV_MSG_STOP:
370
+      break;
371
+    case U8G_DEV_MSG_PAGE_NEXT:
372
+      {
373
+        uint8_t y, i, j;
374
+        uint8_t *ptr;
375
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
376
+        
377
+        u8g_SetAddress(u8g, dev, 0);           /* cmd mode */
378
+        u8g_SetChipSelect(u8g, dev, 1);
379
+        y = pb->p.page_y0;
380
+        ptr = pb->buf;
381
+        
382
+        u8g_SetAddress(u8g, dev, 0);           /* cmd mode */
383
+        u8g_WriteByte(u8g, dev, 0x02a );      /* Column address set 8.1.20 */
384
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
385
+        u8g_WriteByte(u8g, dev, 0x000 );      /* x0 */
386
+        u8g_WriteByte(u8g, dev, WIDTH-1 );      /* x1 */
387
+        u8g_SetAddress(u8g, dev, 0);           /* cmd mode */
388
+        u8g_WriteByte(u8g, dev, 0x02b );      /* Row address set 8.1.21 */
389
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
390
+        u8g_WriteByte(u8g, dev, y );      /* y0 */
391
+        u8g_WriteByte(u8g, dev, y+PAGE_HEIGHT-1 );      /* y1 */
392
+        u8g_SetAddress(u8g, dev, 0);           /* cmd mode */
393
+        u8g_WriteByte(u8g, dev, 0x02c );      /* Memory write 8.1.22 */
394
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
395
+        
396
+        for( i = 0; i < PAGE_HEIGHT; i ++ )
397
+        {
398
+          
399
+          for( j = 0; j < WIDTH; j ++ )
400
+          {
401
+            u8g_WriteByte(u8g, dev, get_byte_1(*ptr) );     
402
+            u8g_WriteByte(u8g, dev, get_byte_2(*ptr) );                 
403
+            ptr++;
404
+          }
405
+        }
406
+        u8g_SetAddress(u8g, dev, 0);           /* cmd mode */
407
+        u8g_SetChipSelect(u8g, dev, 0);
408
+      }
409
+      break;
410
+  }
411
+  return u8g_dev_pb8h8_base_fn(u8g, dev, msg, arg);
412
+}
413
+
414
+
415
+uint8_t u8g_st7687_c144mvgd_8h8_buf[WIDTH*8] U8G_NOCOMMON ; 
416
+u8g_pb_t u8g_st7687_c144mvgd_8h8_pb = { {8, HEIGHT, 0, 0, 0},  WIDTH, u8g_st7687_c144mvgd_8h8_buf}; 
417
+
418
+u8g_dev_t u8g_dev_st7687_c144mvgd_sw_spi = { u8g_dev_st7687_c144mvgd_fn, &u8g_st7687_c144mvgd_8h8_pb, u8g_com_arduino_sw_spi_fn };
419
+
420
+u8g_dev_t u8g_dev_st7687_c144mvgd_8bit = { u8g_dev_st7687_c144mvgd_fn, &u8g_st7687_c144mvgd_8h8_pb, U8G_COM_PARALLEL };

+ 171
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7920_128x64.c View File

@@ -0,0 +1,171 @@
1
+/*
2
+
3
+  u8g_dev_st7565_128x64.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+  
35
+*/
36
+
37
+#include "u8g.h"
38
+
39
+#define WIDTH 128
40
+#define HEIGHT 64
41
+#define PAGE_HEIGHT 8
42
+
43
+
44
+/* init sequence from https://github.com/adafruit/ST7565-LCD/blob/master/ST7565/ST7565.cpp */
45
+static const uint8_t u8g_dev_st7920_128x64_init_seq[] PROGMEM = {
46
+  U8G_ESC_CS(0),             /* disable chip */
47
+  U8G_ESC_ADR(0),           /* instruction mode */
48
+  U8G_ESC_RST(15),           /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
49
+  U8G_ESC_DLY(100),         /* 8 Dez 2012: additional delay 100 ms because of reset*/
50
+  U8G_ESC_CS(1),             /* enable chip */
51
+  U8G_ESC_DLY(50),         /* delay 50 ms */
52
+
53
+  0x038,                                /* 8 Bit interface (DL=1), basic instruction set (RE=0) */
54
+  0x00c,                                /* display on, cursor & blink off; 0x08: all off */
55
+  0x006,                                /* Entry mode: Cursor move to right ,DDRAM address counter (AC) plus 1, no shift */
56
+  0x002,                                /* disable scroll, enable CGRAM adress */
57
+  0x001,                                /* clear RAM, needs 1.6 ms */
58
+  U8G_ESC_DLY(100),               /* delay 100 ms */
59
+  
60
+  U8G_ESC_CS(0),             /* disable chip */
61
+  U8G_ESC_END                /* end of sequence */
62
+};
63
+
64
+uint8_t u8g_dev_st7920_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
65
+{
66
+  switch(msg)
67
+  {
68
+    case U8G_DEV_MSG_INIT:
69
+      u8g_InitCom(u8g, dev);
70
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_128x64_init_seq);
71
+      break;
72
+    case U8G_DEV_MSG_STOP:
73
+      break;
74
+    case U8G_DEV_MSG_PAGE_NEXT:
75
+      {
76
+        uint8_t y, i;
77
+        uint8_t *ptr;
78
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
79
+        
80
+        u8g_SetAddress(u8g, dev, 0);           /* cmd mode */
81
+        u8g_SetChipSelect(u8g, dev, 1);
82
+        y = pb->p.page_y0;
83
+        ptr = pb->buf;
84
+        for( i = 0; i < 8; i ++ )
85
+        {
86
+          u8g_SetAddress(u8g, dev, 0);           /* cmd mode */
87
+          u8g_WriteByte(u8g, dev, 0x03e );      /* enable extended mode */
88
+
89
+          if ( y < 32 )
90
+          {
91
+                  u8g_WriteByte(u8g, dev, 0x080 | y );      /* y pos  */
92
+                  u8g_WriteByte(u8g, dev, 0x080  );      /* set x pos to 0*/
93
+          }
94
+          else
95
+          {
96
+                  u8g_WriteByte(u8g, dev, 0x080 | (y-32) );      /* y pos  */
97
+                  u8g_WriteByte(u8g, dev, 0x080 | 8);      /* set x pos to 64*/
98
+          }
99
+          
100
+          u8g_SetAddress(u8g, dev, 1);                  /* data mode */
101
+          u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
102
+          ptr += WIDTH/8;
103
+          y++;
104
+        }
105
+        u8g_SetChipSelect(u8g, dev, 0);
106
+      }
107
+      break;
108
+  }
109
+  return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg);
110
+}
111
+
112
+uint8_t u8g_dev_st7920_128x64_4x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
113
+{
114
+  switch(msg)
115
+  {
116
+    case U8G_DEV_MSG_INIT:
117
+      u8g_InitCom(u8g, dev);
118
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_128x64_init_seq);
119
+      break;
120
+    case U8G_DEV_MSG_STOP:
121
+      break;
122
+    case U8G_DEV_MSG_PAGE_NEXT:
123
+      {
124
+        uint8_t y, i;
125
+        uint8_t *ptr;
126
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
127
+        
128
+        u8g_SetAddress(u8g, dev, 0);           /* cmd mode */
129
+        u8g_SetChipSelect(u8g, dev, 1);
130
+        y = pb->p.page_y0;
131
+        ptr = pb->buf;
132
+        for( i = 0; i < 32; i ++ )
133
+        {
134
+          u8g_SetAddress(u8g, dev, 0);           /* cmd mode */
135
+          u8g_WriteByte(u8g, dev, 0x03e );      /* enable extended mode */
136
+
137
+          if ( y < 32 )
138
+          {
139
+                  u8g_WriteByte(u8g, dev, 0x080 | y );      /* y pos  */
140
+                  u8g_WriteByte(u8g, dev, 0x080  );      /* set x pos to 0*/
141
+          }
142
+          else
143
+          {
144
+                  u8g_WriteByte(u8g, dev, 0x080 | (y-32) );      /* y pos  */
145
+                  u8g_WriteByte(u8g, dev, 0x080 | 8);      /* set x pos to 64*/
146
+          }
147
+          
148
+          u8g_SetAddress(u8g, dev, 1);                  /* data mode */
149
+          u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
150
+          ptr += WIDTH/8;
151
+          y++;
152
+        }
153
+        u8g_SetChipSelect(u8g, dev, 0);
154
+      }
155
+      break;
156
+  }
157
+  return u8g_dev_pb32h1_base_fn(u8g, dev, msg, arg);
158
+}
159
+
160
+U8G_PB_DEV(u8g_dev_st7920_128x64_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_128x64_fn, U8G_COM_ST7920_SW_SPI);
161
+U8G_PB_DEV(u8g_dev_st7920_128x64_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_128x64_fn, U8G_COM_ST7920_HW_SPI);
162
+U8G_PB_DEV(u8g_dev_st7920_128x64_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_128x64_fn, U8G_COM_FAST_PARALLEL);
163
+
164
+#define QWIDTH (WIDTH*4)
165
+uint8_t u8g_dev_st7920_128x64_4x_buf[QWIDTH] U8G_NOCOMMON ; 
166
+u8g_pb_t u8g_dev_st7920_128x64_4x_pb = { {32, HEIGHT, 0, 0, 0},  WIDTH, u8g_dev_st7920_128x64_4x_buf}; 
167
+u8g_dev_t u8g_dev_st7920_128x64_4x_sw_spi = { u8g_dev_st7920_128x64_4x_fn, &u8g_dev_st7920_128x64_4x_pb, U8G_COM_ST7920_SW_SPI };
168
+u8g_dev_t u8g_dev_st7920_128x64_4x_hw_spi = { u8g_dev_st7920_128x64_4x_fn, &u8g_dev_st7920_128x64_4x_pb, U8G_COM_ST7920_HW_SPI };
169
+u8g_dev_t u8g_dev_st7920_128x64_4x_8bit = { u8g_dev_st7920_128x64_4x_fn, &u8g_dev_st7920_128x64_4x_pb, U8G_COM_FAST_PARALLEL };
170
+
171
+

+ 151
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7920_192x32.c View File

@@ -0,0 +1,151 @@
1
+/*
2
+
3
+  u8g_dev_st7920_192x32.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+  
35
+*/
36
+
37
+#include "u8g.h"
38
+
39
+#define WIDTH 192
40
+#define HEIGHT 32
41
+
42
+
43
+/* init sequence from https://github.com/adafruit/ST7565-LCD/blob/master/ST7565/ST7565.cpp */
44
+static const uint8_t u8g_dev_st7920_192x32_init_seq[] PROGMEM = {
45
+  U8G_ESC_CS(0),             /* disable chip */
46
+  U8G_ESC_ADR(0),           /* instruction mode */
47
+  U8G_ESC_RST(15),           /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
48
+  U8G_ESC_DLY(100),         /* 8 Dez 2012: additional delay 100 ms because of reset*/
49
+  U8G_ESC_CS(1),             /* enable chip */
50
+  U8G_ESC_DLY(50),         /* delay 50 ms */
51
+
52
+  0x038,                                /* 8 Bit interface (DL=1), basic instruction set (RE=0) */
53
+  0x00c,                                /* display on, cursor & blink off; 0x08: all off */
54
+  0x006,                                /* Entry mode: Cursor move to right ,DDRAM address counter (AC) plus 1, no shift */
55
+  0x002,                                /* disable scroll, enable CGRAM adress */
56
+  0x001,                                /* clear RAM, needs 1.6 ms */
57
+  U8G_ESC_DLY(100),               /* delay 10 ms */
58
+  
59
+  U8G_ESC_CS(0),             /* disable chip */
60
+  U8G_ESC_END                /* end of sequence */
61
+};
62
+
63
+uint8_t u8g_dev_st7920_192x32_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
64
+{
65
+  switch(msg)
66
+  {
67
+    case U8G_DEV_MSG_INIT:
68
+      u8g_InitCom(u8g, dev);
69
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_192x32_init_seq);
70
+      break;
71
+    case U8G_DEV_MSG_STOP:
72
+      break;
73
+    case U8G_DEV_MSG_PAGE_NEXT:
74
+      {
75
+        uint8_t y, i;
76
+        uint8_t *ptr;
77
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
78
+        
79
+        u8g_SetAddress(u8g, dev, 0);           /* cmd mode */
80
+        u8g_SetChipSelect(u8g, dev, 1);
81
+        y = pb->p.page_y0;
82
+        ptr = pb->buf;
83
+        for( i = 0; i < 8; i ++ )
84
+        {
85
+          u8g_SetAddress(u8g, dev, 0);           /* cmd mode */
86
+          u8g_WriteByte(u8g, dev, 0x03e );      /* enable extended mode */
87
+          u8g_WriteByte(u8g, dev, 0x080 | y );      /* y pos  */
88
+          u8g_WriteByte(u8g, dev, 0x080  );      /* set x pos to 0*/          
89
+          u8g_SetAddress(u8g, dev, 1);                  /* data mode */
90
+          u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
91
+          ptr += WIDTH/8;
92
+          y++;
93
+        }
94
+        u8g_SetChipSelect(u8g, dev, 0);
95
+      }
96
+      break;
97
+  }
98
+  return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg);
99
+}
100
+
101
+uint8_t u8g_dev_st7920_192x32_4x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
102
+{
103
+  switch(msg)
104
+  {
105
+    case U8G_DEV_MSG_INIT:
106
+      u8g_InitCom(u8g, dev);
107
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_192x32_init_seq);
108
+      break;
109
+    case U8G_DEV_MSG_STOP:
110
+      break;
111
+    case U8G_DEV_MSG_PAGE_NEXT:
112
+      {
113
+        uint8_t y, i;
114
+        uint8_t *ptr;
115
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
116
+        
117
+        u8g_SetAddress(u8g, dev, 0);           /* cmd mode */
118
+        u8g_SetChipSelect(u8g, dev, 1);
119
+        y = pb->p.page_y0;
120
+        ptr = pb->buf;
121
+        for( i = 0; i < 32; i ++ )
122
+        {
123
+          u8g_SetAddress(u8g, dev, 0);           /* cmd mode */
124
+          u8g_WriteByte(u8g, dev, 0x03e );      /* enable extended mode */
125
+          u8g_WriteByte(u8g, dev, 0x080 | y );      /* y pos  */
126
+          u8g_WriteByte(u8g, dev, 0x080  );      /* set x pos to 0*/          
127
+          u8g_SetAddress(u8g, dev, 1);                  /* data mode */
128
+          u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
129
+          ptr += WIDTH/8;
130
+          y++;
131
+        }
132
+        u8g_SetChipSelect(u8g, dev, 0);
133
+      }
134
+      break;
135
+  }
136
+  return u8g_dev_pb32h1_base_fn(u8g, dev, msg, arg);
137
+}
138
+
139
+
140
+U8G_PB_DEV(u8g_dev_st7920_192x32_sw_spi, WIDTH, HEIGHT, 8, u8g_dev_st7920_192x32_fn, U8G_COM_ST7920_SW_SPI);
141
+U8G_PB_DEV(u8g_dev_st7920_192x32_hw_spi, WIDTH, HEIGHT, 8, u8g_dev_st7920_192x32_fn, U8G_COM_ST7920_HW_SPI);
142
+U8G_PB_DEV(u8g_dev_st7920_192x32_8bit, WIDTH, HEIGHT, 8, u8g_dev_st7920_192x32_fn, U8G_COM_FAST_PARALLEL);
143
+
144
+
145
+#define QWIDTH (WIDTH*4)
146
+uint8_t u8g_dev_st7920_192x32_4x_buf[QWIDTH] U8G_NOCOMMON ; 
147
+u8g_pb_t u8g_dev_st7920_192x32_4x_pb = { {32, HEIGHT, 0, 0, 0},  WIDTH, u8g_dev_st7920_192x32_4x_buf}; 
148
+u8g_dev_t u8g_dev_st7920_192x32_4x_sw_spi = { u8g_dev_st7920_192x32_4x_fn, &u8g_dev_st7920_192x32_4x_pb, U8G_COM_ST7920_SW_SPI };
149
+u8g_dev_t u8g_dev_st7920_192x32_4x_hw_spi = { u8g_dev_st7920_192x32_4x_fn, &u8g_dev_st7920_192x32_4x_pb, U8G_COM_ST7920_HW_SPI };
150
+u8g_dev_t u8g_dev_st7920_192x32_4x_8bit = { u8g_dev_st7920_192x32_4x_fn, &u8g_dev_st7920_192x32_4x_pb, U8G_COM_FAST_PARALLEL };
151
+

+ 154
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7920_202x32.c View File

@@ -0,0 +1,154 @@
1
+/*
2
+
3
+  u8g_dev_st7920_202x32.c
4
+  tested with CFAG20232
5
+  
6
+
7
+  Universal 8bit Graphics Library
8
+  
9
+  Copyright (c) 2011, olikraus@gmail.com
10
+  All rights reserved.
11
+
12
+  Redistribution and use in source and binary forms, with or without modification, 
13
+  are permitted provided that the following conditions are met:
14
+
15
+  * Redistributions of source code must retain the above copyright notice, this list 
16
+    of conditions and the following disclaimer.
17
+    
18
+  * Redistributions in binary form must reproduce the above copyright notice, this 
19
+    list of conditions and the following disclaimer in the documentation and/or other 
20
+    materials provided with the distribution.
21
+
22
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
23
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
24
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
25
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
26
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
27
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
28
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
29
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
30
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
31
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
32
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
33
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
34
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
35
+  
36
+  
37
+*/
38
+
39
+#include "u8g.h"
40
+
41
+#define WIDTH 202
42
+#define HEIGHT 32
43
+#define PAGE_HEIGHT 8
44
+
45
+
46
+/* init sequence from https://github.com/adafruit/ST7565-LCD/blob/master/ST7565/ST7565.cpp */
47
+static const uint8_t u8g_dev_st7920_202x32_init_seq[] PROGMEM = {
48
+  U8G_ESC_CS(0),             /* disable chip */
49
+  U8G_ESC_ADR(0),           /* instruction mode */
50
+  U8G_ESC_RST(15),           /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
51
+  U8G_ESC_DLY(100),         /* 8 Dez 2012: additional delay 100 ms because of reset*/
52
+  U8G_ESC_CS(1),             /* enable chip */
53
+  U8G_ESC_DLY(50),         /* delay 50 ms */
54
+
55
+  0x038,                                /* 8 Bit interface (DL=1), basic instruction set (RE=0) */
56
+  0x00c,                                /* display on, cursor & blink off; 0x08: all off */
57
+  0x006,                                /* Entry mode: Cursor move to right ,DDRAM address counter (AC) plus 1, no shift */
58
+  0x002,                                /* disable scroll, enable CGRAM adress */
59
+  0x001,                                /* clear RAM, needs 1.6 ms */
60
+  U8G_ESC_DLY(100),               /* delay 10 ms */
61
+  
62
+  U8G_ESC_CS(0),             /* disable chip */
63
+  U8G_ESC_END                /* end of sequence */
64
+};
65
+
66
+uint8_t u8g_dev_st7920_202x32_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
67
+{
68
+  switch(msg)
69
+  {
70
+    case U8G_DEV_MSG_INIT:
71
+      u8g_InitCom(u8g, dev);
72
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_202x32_init_seq);
73
+      break;
74
+    case U8G_DEV_MSG_STOP:
75
+      break;
76
+    case U8G_DEV_MSG_PAGE_NEXT:
77
+      {
78
+        uint8_t y, i;
79
+        uint8_t *ptr;
80
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
81
+        
82
+        u8g_SetAddress(u8g, dev, 0);           /* cmd mode */
83
+        u8g_SetChipSelect(u8g, dev, 1);
84
+        y = pb->p.page_y0;
85
+        ptr = pb->buf;
86
+        for( i = 0; i < 8; i ++ )
87
+        {
88
+          u8g_SetAddress(u8g, dev, 0);           /* cmd mode */
89
+          u8g_WriteByte(u8g, dev, 0x03e );      /* enable extended mode */
90
+          u8g_WriteByte(u8g, dev, 0x080 | y );      /* y pos  */
91
+          u8g_WriteByte(u8g, dev, 0x080  );      /* set x pos to 0*/          
92
+          u8g_SetAddress(u8g, dev, 1);                  /* data mode */
93
+          u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
94
+          ptr += WIDTH/8;
95
+          y++;
96
+        }
97
+        u8g_SetChipSelect(u8g, dev, 0);
98
+      }
99
+      break;
100
+  }
101
+  return u8g_dev_pb8h1_base_fn(u8g, dev, msg, arg);
102
+}
103
+
104
+uint8_t u8g_dev_st7920_202x32_4x_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
105
+{
106
+  switch(msg)
107
+  {
108
+    case U8G_DEV_MSG_INIT:
109
+      u8g_InitCom(u8g, dev);
110
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_st7920_202x32_init_seq);
111
+      break;
112
+    case U8G_DEV_MSG_STOP:
113
+      break;
114
+    case U8G_DEV_MSG_PAGE_NEXT:
115
+      {
116
+        uint8_t y, i;
117
+        uint8_t *ptr;
118
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
119
+        
120
+        u8g_SetAddress(u8g, dev, 0);           /* cmd mode */
121
+        u8g_SetChipSelect(u8g, dev, 1);
122
+        y = pb->p.page_y0;
123
+        ptr = pb->buf;
124
+        for( i = 0; i < 32; i ++ )
125
+        {
126
+          u8g_SetAddress(u8g, dev, 0);           /* cmd mode */
127
+          u8g_WriteByte(u8g, dev, 0x03e );      /* enable extended mode */
128
+          u8g_WriteByte(u8g, dev, 0x080 | y );      /* y pos  */
129
+          u8g_WriteByte(u8g, dev, 0x080  );      /* set x pos to 0*/          
130
+          u8g_SetAddress(u8g, dev, 1);                  /* data mode */
131
+          u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);
132
+          ptr += WIDTH/8;
133
+          y++;
134
+        }
135
+        u8g_SetChipSelect(u8g, dev, 0);
136
+      }
137
+      break;
138
+  }
139
+  return u8g_dev_pb32h1_base_fn(u8g, dev, msg, arg);
140
+}
141
+
142
+
143
+U8G_PB_DEV(u8g_dev_st7920_202x32_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_202x32_fn, U8G_COM_ST7920_SW_SPI);
144
+U8G_PB_DEV(u8g_dev_st7920_202x32_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_202x32_fn, U8G_COM_ST7920_HW_SPI);
145
+U8G_PB_DEV(u8g_dev_st7920_202x32_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_st7920_202x32_fn, U8G_COM_FAST_PARALLEL);
146
+
147
+#define QWIDTH (WIDTH*4)
148
+uint8_t u8g_dev_st7920_202x32_4x_buf[QWIDTH] U8G_NOCOMMON ; 
149
+u8g_pb_t u8g_dev_st7920_202x32_4x_pb = { {32, HEIGHT, 0, 0, 0},  WIDTH, u8g_dev_st7920_202x32_4x_buf}; 
150
+u8g_dev_t u8g_dev_st7920_202x32_4x_sw_spi = { u8g_dev_st7920_202x32_4x_fn, &u8g_dev_st7920_202x32_4x_pb, U8G_COM_ST7920_SW_SPI };
151
+u8g_dev_t u8g_dev_st7920_202x32_4x_hw_spi = { u8g_dev_st7920_202x32_4x_fn, &u8g_dev_st7920_202x32_4x_pb, U8G_COM_ST7920_HW_SPI };
152
+u8g_dev_t u8g_dev_st7920_202x32_4x_8bit = { u8g_dev_st7920_202x32_4x_fn, &u8g_dev_st7920_202x32_4x_pb, U8G_COM_FAST_PARALLEL };
153
+
154
+

+ 191
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_t6963_128x64.c View File

@@ -0,0 +1,191 @@
1
+/*
2
+
3
+  u8g_dev_t6963_128x64.c
4
+  
5
+  Tested with Varitronix MGLS240128TZ
6
+  
7
+  Universal 8bit Graphics Library
8
+  
9
+  Copyright (c) 2013, olikraus@gmail.com
10
+  All rights reserved.
11
+
12
+  Redistribution and use in source and binary forms, with or without modification, 
13
+  are permitted provided that the following conditions are met:
14
+
15
+  * Redistributions of source code must retain the above copyright notice, this list 
16
+    of conditions and the following disclaimer.
17
+    
18
+  * Redistributions in binary form must reproduce the above copyright notice, this 
19
+    list of conditions and the following disclaimer in the documentation and/or other 
20
+    materials provided with the distribution.
21
+
22
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
23
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
24
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
25
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
26
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
27
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
28
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
29
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
30
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
31
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
32
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
33
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
34
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
35
+  
36
+        
37
+  Application Notes for the MGLS 240x128
38
+    www.baso.no/content/pdf/T6963C_Application.pdf
39
+  
40
+  Hitachi App Notes:
41
+    https://www.sparkfun.com/datasheets/LCD/Monochrome/AN-029-Toshiba_T6963C.pdf
42
+
43
+  Notes:
44
+    The font selection pins should generate the 8x8 font.
45
+    For the MGLS240128TZ only FS1 is available on pin 18.
46
+    FS1 must be low to generate the 8x8 font.
47
+  
48
+  
49
+*/
50
+
51
+#include "u8g.h"
52
+
53
+#define WIDTH 128
54
+#define HEIGHT 64
55
+#define PAGE_HEIGHT 16
56
+
57
+
58
+/* text is not used, so settings are not relevant */
59
+static const uint8_t u8g_dev_t6963_128x64_init_seq[] PROGMEM = {
60
+  U8G_ESC_CS(0),             /* disable chip */
61
+  U8G_ESC_ADR(0),           /* data mode */
62
+  U8G_ESC_RST(15),           /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
63
+
64
+  U8G_ESC_CS(1),             /* enable chip */
65
+  U8G_ESC_DLY(50),         /* delay 50 ms */
66
+
67
+  U8G_ESC_ADR(0),               /* data mode */
68
+  0x000,                                /* low byte */
69
+  0x000,                                /* height byte */
70
+  U8G_ESC_ADR(1),               /* instruction mode */
71
+  0x021,                                /* set cursor position */
72
+  
73
+  U8G_ESC_ADR(0),               /* data mode */
74
+  0x000,                                /* low byte */
75
+  0x000,                                /* height byte */
76
+  U8G_ESC_ADR(1),               /* instruction mode */
77
+  0x022,                                /* set offset */
78
+
79
+  U8G_ESC_ADR(0),               /* data mode */
80
+  0x000,                                /* low byte */
81
+  0x000,                                /* height byte */
82
+  U8G_ESC_ADR(1),               /* instruction mode */
83
+  0x040,				     /* text home */
84
+
85
+  U8G_ESC_ADR(0),               /* data mode */
86
+  WIDTH/8,                      	    /* low byte */
87
+  0x000,                                /* height byte */
88
+  U8G_ESC_ADR(1),               /* instruction mode */
89
+  0x041,				     /* text columns */
90
+
91
+  U8G_ESC_ADR(0),               /* data mode */
92
+  0x000,                                /* low byte */
93
+  0x000,                                /* height byte */
94
+  U8G_ESC_ADR(1),               /* instruction mode */
95
+  0x042,				     /* graphics home */
96
+
97
+  U8G_ESC_ADR(0),               /* data mode */
98
+  WIDTH/8,                      /* low byte */
99
+  0x000,                                /* height byte */
100
+  U8G_ESC_ADR(1),               /* instruction mode */
101
+  0x043,				     /* graphics columns */
102
+  
103
+  // mode set
104
+  // 0x080: Internal CG, OR Mode
105
+  // 0x081: Internal CG, EXOR Mode
106
+  // 0x083: Internal CG, AND Mode
107
+  // 0x088: External CG, OR Mode
108
+  // 0x089: External CG, EXOR Mode
109
+  // 0x08B: External CG, AND Mode
110
+  U8G_ESC_ADR(1),               /* instruction mode */
111
+  0x080,                                /* mode register: OR Mode, Internal Character Mode */
112
+  
113
+  U8G_ESC_ADR(1),               /* instruction mode */
114
+  // display mode
115
+  // 0x090: Display off
116
+  // 0x094: Graphic off, text on, cursor off, blink off
117
+  // 0x096: Graphic off, text on, cursor on, blink off
118
+  // 0x097: Graphic off, text on, cursor on, blink on
119
+  // 0x098: Graphic on, text off, cursor off, blink off
120
+  // 0x09a: Graphic on, text off, cursor on, blink off
121
+  // ...
122
+  // 0x09c: Graphic on, text on, cursor off, blink off
123
+  // 0x09f: Graphic on, text on, cursor on, blink on
124
+  0x098,                                /* mode register: Display Mode, Graphics on, Text off, Cursor off */
125
+  
126
+  U8G_ESC_ADR(0),               /* data mode */
127
+  0x000,                                /* low byte */
128
+  0x000,                                /* height byte */
129
+  U8G_ESC_ADR(1),               /* instruction mode */
130
+  0x024,                                /* set adr pointer */
131
+  
132
+
133
+  U8G_ESC_DLY(100),         /* delay 100 ms */
134
+  
135
+  U8G_ESC_ADR(0),               /* data mode */
136
+  U8G_ESC_CS(0),             /* disable chip */
137
+  U8G_ESC_END                /* end of sequence */
138
+};
139
+
140
+uint8_t u8g_dev_t6963_128x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
141
+{
142
+  switch(msg)
143
+  {
144
+    case U8G_DEV_MSG_INIT:
145
+      u8g_InitCom(u8g, dev);    
146
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_t6963_128x64_init_seq);
147
+      break;
148
+    case U8G_DEV_MSG_STOP:
149
+      break;
150
+    case U8G_DEV_MSG_PAGE_NEXT:
151
+      {
152
+        uint8_t y, i;
153
+        uint16_t disp_ram_adr;
154
+        uint8_t *ptr;
155
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
156
+
157
+        
158
+	u8g_SetAddress(u8g, dev, 0);           /* data mode */
159
+        u8g_SetChipSelect(u8g, dev, 1);
160
+        y = pb->p.page_y0;
161
+        ptr = pb->buf;
162
+        disp_ram_adr = WIDTH/8;
163
+        disp_ram_adr *= y;
164
+        for( i = 0; i < PAGE_HEIGHT; i ++ )
165
+        {
166
+          u8g_SetAddress(u8g, dev, 0);           /* data mode */
167
+          u8g_WriteByte(u8g, dev, disp_ram_adr&255 );      /* address low byte */
168
+          u8g_WriteByte(u8g, dev, disp_ram_adr>>8 );      /* address hight byte */
169
+          u8g_SetAddress(u8g, dev, 1);           /* cmd mode */
170
+          u8g_WriteByte(u8g, dev, 0x024 );      /* set adr ptr */
171
+	  
172
+          u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);	
173
+	  
174
+          ptr += WIDTH/8;
175
+          disp_ram_adr += WIDTH/8;
176
+        }
177
+	u8g_SetAddress(u8g, dev, 0);           /* data mode */
178
+        u8g_SetChipSelect(u8g, dev, 0);
179
+      }
180
+      break;
181
+  }
182
+  return u8g_dev_pb16h1_base_fn(u8g, dev, msg, arg);
183
+}
184
+
185
+// U8G_PB_DEV(u8g_dev_t6963_128x64_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_t6963_128x64_fn, U8G_COM_T6963);
186
+
187
+uint8_t u8g_dev_t6963_128x64_2x_bw_buf[WIDTH/8*PAGE_HEIGHT] U8G_NOCOMMON ; 
188
+u8g_pb_t u8g_dev_t6963_128x64_2x_bw_pb = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0},  WIDTH, u8g_dev_t6963_128x64_2x_bw_buf}; 
189
+u8g_dev_t u8g_dev_t6963_128x64_8bit = { u8g_dev_t6963_128x64_fn, &u8g_dev_t6963_128x64_2x_bw_pb, U8G_COM_T6963 };
190
+
191
+

+ 195
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_t6963_240x128.c View File

@@ -0,0 +1,195 @@
1
+/*
2
+
3
+  u8g_dev_t6963_240x128.c
4
+  
5
+  Tested with Varitronix MGLS240128TZ
6
+  
7
+  Universal 8bit Graphics Library
8
+  
9
+  Copyright (c) 2013, olikraus@gmail.com
10
+  All rights reserved.
11
+
12
+  Redistribution and use in source and binary forms, with or without modification, 
13
+  are permitted provided that the following conditions are met:
14
+
15
+  * Redistributions of source code must retain the above copyright notice, this list 
16
+    of conditions and the following disclaimer.
17
+    
18
+  * Redistributions in binary form must reproduce the above copyright notice, this 
19
+    list of conditions and the following disclaimer in the documentation and/or other 
20
+    materials provided with the distribution.
21
+
22
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
23
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
24
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
25
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
26
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
27
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
28
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
29
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
30
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
31
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
32
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
33
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
34
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
35
+    
36
+        
37
+  Application Notes for the MGLS 240x128
38
+    www.baso.no/content/pdf/T6963C_Application.pdf
39
+  
40
+  Hitachi App Notes:
41
+    https://www.sparkfun.com/datasheets/LCD/Monochrome/AN-029-Toshiba_T6963C.pdf
42
+
43
+  Notes:
44
+    The font selection pins should generate the 8x8 font.
45
+    For the MGLS240128TZ only FS1 is available on pin 18.
46
+    FS1 must be low to generate the 8x8 font.
47
+  
48
+
49
+*/
50
+
51
+#include "u8g.h"
52
+
53
+#define WIDTH 240
54
+#define HEIGHT 128
55
+#define PAGE_HEIGHT 16
56
+
57
+
58
+/*
59
+  http://www.mark-products.com/graphics.htm#240x64%20Pixel%20Format
60
+*/
61
+
62
+/* text is not used, so settings are not relevant */
63
+static const uint8_t u8g_dev_t6963_240x128_init_seq[] PROGMEM = {
64
+  U8G_ESC_CS(0),             /* disable chip */
65
+  U8G_ESC_ADR(0),           /* data mode */
66
+  U8G_ESC_RST(15),           /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
67
+
68
+  U8G_ESC_CS(1),             /* enable chip */
69
+  U8G_ESC_DLY(50),         /* delay 50 ms */
70
+
71
+  U8G_ESC_ADR(0),               /* data mode */
72
+  0x000,                                /* low byte */
73
+  0x000,                                /* height byte */
74
+  U8G_ESC_ADR(1),               /* instruction mode */
75
+  0x021,                                /* set cursor position */
76
+  
77
+  U8G_ESC_ADR(0),               /* data mode */
78
+  0x000,                                /* low byte */
79
+  0x000,                                /* height byte */
80
+  U8G_ESC_ADR(1),               /* instruction mode */
81
+  0x022,                                /* set offset */
82
+
83
+  U8G_ESC_ADR(0),               /* data mode */
84
+  0x000,                                /* low byte */
85
+  0x000,                                /* height byte */
86
+  U8G_ESC_ADR(1),               /* instruction mode */
87
+  0x040,				     /* text home */
88
+
89
+  U8G_ESC_ADR(0),               /* data mode */
90
+  WIDTH/8,                      	    /* low byte */
91
+  0x000,                                /* height byte */
92
+  U8G_ESC_ADR(1),               /* instruction mode */
93
+  0x041,				     /* text columns */
94
+
95
+  U8G_ESC_ADR(0),               /* data mode */
96
+  0x000,                                /* low byte */
97
+  0x000,                                /* height byte */
98
+  U8G_ESC_ADR(1),               /* instruction mode */
99
+  0x042,				     /* graphics home */
100
+
101
+  U8G_ESC_ADR(0),               /* data mode */
102
+  WIDTH/8,                            /* low byte */
103
+  0x000,                                /* height byte */
104
+  U8G_ESC_ADR(1),               /* instruction mode */
105
+  0x043,				     /* graphics columns */
106
+  
107
+  // mode set
108
+  // 0x080: Internal CG, OR Mode
109
+  // 0x081: Internal CG, EXOR Mode
110
+  // 0x083: Internal CG, AND Mode
111
+  // 0x088: External CG, OR Mode
112
+  // 0x089: External CG, EXOR Mode
113
+  // 0x08B: External CG, AND Mode
114
+  U8G_ESC_ADR(1),               /* instruction mode */
115
+  0x080,                                /* mode register: OR Mode, Internal Character Mode */
116
+  
117
+  U8G_ESC_ADR(1),               /* instruction mode */
118
+  // display mode
119
+  // 0x090: Display off
120
+  // 0x094: Graphic off, text on, cursor off, blink off
121
+  // 0x096: Graphic off, text on, cursor on, blink off
122
+  // 0x097: Graphic off, text on, cursor on, blink on
123
+  // 0x098: Graphic on, text off, cursor off, blink off
124
+  // 0x09a: Graphic on, text off, cursor on, blink off
125
+  // ...
126
+  // 0x09c: Graphic on, text on, cursor off, blink off
127
+  // 0x09f: Graphic on, text on, cursor on, blink on
128
+  0x098,                                /* mode register: Display Mode, Graphics on, Text off, Cursor off */
129
+  
130
+  U8G_ESC_ADR(0),               /* data mode */
131
+  0x000,                                /* low byte */
132
+  0x000,                                /* height byte */
133
+  U8G_ESC_ADR(1),               /* instruction mode */
134
+  0x024,                                /* set adr pointer */
135
+  
136
+
137
+  U8G_ESC_DLY(100),         /* delay 100 ms */
138
+  
139
+  U8G_ESC_ADR(0),               /* data mode */
140
+  U8G_ESC_CS(0),             /* disable chip */
141
+  U8G_ESC_END                /* end of sequence */
142
+};
143
+
144
+uint8_t u8g_dev_t6963_240x128_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
145
+{
146
+  switch(msg)
147
+  {
148
+    case U8G_DEV_MSG_INIT:
149
+      u8g_InitCom(u8g, dev);    
150
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_t6963_240x128_init_seq);
151
+      break;
152
+    case U8G_DEV_MSG_STOP:
153
+      break;
154
+    case U8G_DEV_MSG_PAGE_NEXT:
155
+      {
156
+        uint8_t y, i;
157
+        uint16_t disp_ram_adr;
158
+        uint8_t *ptr;
159
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
160
+
161
+        
162
+	u8g_SetAddress(u8g, dev, 0);           /* data mode */
163
+        u8g_SetChipSelect(u8g, dev, 1);
164
+        y = pb->p.page_y0;
165
+        ptr = pb->buf;
166
+        disp_ram_adr = WIDTH/8;
167
+        disp_ram_adr *= y;
168
+        for( i = 0; i < PAGE_HEIGHT; i ++ )
169
+        {
170
+          u8g_SetAddress(u8g, dev, 0);           /* data mode */
171
+          u8g_WriteByte(u8g, dev, disp_ram_adr&255 );      /* address low byte */
172
+          u8g_WriteByte(u8g, dev, disp_ram_adr>>8 );      /* address hight byte */
173
+          u8g_SetAddress(u8g, dev, 1);           /* cmd mode */
174
+          u8g_WriteByte(u8g, dev, 0x024 );      /* set adr ptr */
175
+	  
176
+          u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);	
177
+	  
178
+          ptr += WIDTH/8;
179
+          disp_ram_adr += WIDTH/8;
180
+        }
181
+	u8g_SetAddress(u8g, dev, 0);           /* data mode */
182
+        u8g_SetChipSelect(u8g, dev, 0);
183
+      }
184
+      break;
185
+  }
186
+  return u8g_dev_pb16h1_base_fn(u8g, dev, msg, arg);
187
+}
188
+
189
+// U8G_PB_DEV(u8g_dev_t6963_240x128_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_t6963_240x128_fn, U8G_COM_T6963);
190
+
191
+uint8_t u8g_dev_t6963_240x128_2x_bw_buf[WIDTH/8*PAGE_HEIGHT] U8G_NOCOMMON ; 
192
+u8g_pb_t u8g_dev_t6963_240x128_2x_bw_pb = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0},  WIDTH, u8g_dev_t6963_240x128_2x_bw_buf}; 
193
+u8g_dev_t u8g_dev_t6963_240x128_8bit = { u8g_dev_t6963_240x128_fn, &u8g_dev_t6963_240x128_2x_bw_pb, U8G_COM_T6963 };
194
+
195
+

+ 195
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_t6963_240x64.c View File

@@ -0,0 +1,195 @@
1
+/*
2
+
3
+  u8g_dev_t6963_240x64.c
4
+  
5
+  Tested with Varitronix MGLS240128TZ
6
+  
7
+  Universal 8bit Graphics Library
8
+  
9
+  Copyright (c) 2013, olikraus@gmail.com
10
+  All rights reserved.
11
+
12
+  Redistribution and use in source and binary forms, with or without modification, 
13
+  are permitted provided that the following conditions are met:
14
+
15
+  * Redistributions of source code must retain the above copyright notice, this list 
16
+    of conditions and the following disclaimer.
17
+    
18
+  * Redistributions in binary form must reproduce the above copyright notice, this 
19
+    list of conditions and the following disclaimer in the documentation and/or other 
20
+    materials provided with the distribution.
21
+
22
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
23
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
24
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
25
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
26
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
27
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
28
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
29
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
30
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
31
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
32
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
33
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
34
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
35
+  
36
+        
37
+  Application Notes for the MGLS 240x128
38
+    www.baso.no/content/pdf/T6963C_Application.pdf
39
+  
40
+  Hitachi App Notes:
41
+    https://www.sparkfun.com/datasheets/LCD/Monochrome/AN-029-Toshiba_T6963C.pdf
42
+
43
+  Notes:
44
+    The font selection pins should generate the 8x8 font.
45
+    For the MGLS240128TZ only FS1 is available on pin 18.
46
+    FS1 must be low to generate the 8x8 font.
47
+  
48
+  
49
+*/
50
+
51
+#include "u8g.h"
52
+
53
+#define WIDTH 240
54
+#define HEIGHT 64
55
+#define PAGE_HEIGHT 16
56
+
57
+
58
+/*
59
+  http://www.mark-products.com/graphics.htm#240x64%20Pixel%20Format
60
+*/
61
+
62
+/* text is not used, so settings are not relevant */
63
+static const uint8_t u8g_dev_t6963_240x64_init_seq[] PROGMEM = {
64
+  U8G_ESC_CS(0),             /* disable chip */
65
+  U8G_ESC_ADR(0),           /* data mode */
66
+  U8G_ESC_RST(15),           /* do reset low pulse with (15*16)+2 milliseconds (=maximum delay)*/
67
+
68
+  U8G_ESC_CS(1),             /* enable chip */
69
+  U8G_ESC_DLY(50),         /* delay 50 ms */
70
+
71
+  U8G_ESC_ADR(0),               /* data mode */
72
+  0x000,                                /* low byte */
73
+  0x000,                                /* height byte */
74
+  U8G_ESC_ADR(1),               /* instruction mode */
75
+  0x021,                                /* set cursor position */
76
+  
77
+  U8G_ESC_ADR(0),               /* data mode */
78
+  0x000,                                /* low byte */
79
+  0x000,                                /* height byte */
80
+  U8G_ESC_ADR(1),               /* instruction mode */
81
+  0x022,                                /* set offset */
82
+
83
+  U8G_ESC_ADR(0),               /* data mode */
84
+  0x000,                                /* low byte */
85
+  0x000,                                /* height byte */
86
+  U8G_ESC_ADR(1),               /* instruction mode */
87
+  0x040,				     /* text home */
88
+
89
+  U8G_ESC_ADR(0),               /* data mode */
90
+  WIDTH/8,                      /* low byte */
91
+  0x000,                                /* height byte */
92
+  U8G_ESC_ADR(1),               /* instruction mode */
93
+  0x041,				     /* text columns */
94
+
95
+  U8G_ESC_ADR(0),               /* data mode */
96
+  0x000,                                /* low byte */
97
+  0x000,                                /* height byte */
98
+  U8G_ESC_ADR(1),               /* instruction mode */
99
+  0x042,				     /* graphics home */
100
+
101
+  U8G_ESC_ADR(0),               /* data mode */
102
+  WIDTH/8,                      /* low byte */
103
+  0x000,                                /* height byte */
104
+  U8G_ESC_ADR(1),               /* instruction mode */
105
+  0x043,				     /* graphics columns */
106
+  
107
+  // mode set
108
+  // 0x080: Internal CG, OR Mode
109
+  // 0x081: Internal CG, EXOR Mode
110
+  // 0x083: Internal CG, AND Mode
111
+  // 0x088: External CG, OR Mode
112
+  // 0x089: External CG, EXOR Mode
113
+  // 0x08B: External CG, AND Mode
114
+  U8G_ESC_ADR(1),               /* instruction mode */
115
+  0x080,                                /* mode register: OR Mode, Internal Character Mode */
116
+  
117
+  U8G_ESC_ADR(1),               /* instruction mode */
118
+  // display mode
119
+  // 0x090: Display off
120
+  // 0x094: Graphic off, text on, cursor off, blink off
121
+  // 0x096: Graphic off, text on, cursor on, blink off
122
+  // 0x097: Graphic off, text on, cursor on, blink on
123
+  // 0x098: Graphic on, text off, cursor off, blink off
124
+  // 0x09a: Graphic on, text off, cursor on, blink off
125
+  // ...
126
+  // 0x09c: Graphic on, text on, cursor off, blink off
127
+  // 0x09f: Graphic on, text on, cursor on, blink on
128
+  0x098,                                /* mode register: Display Mode, Graphics on, Text off, Cursor off */
129
+  
130
+  U8G_ESC_ADR(0),               /* data mode */
131
+  0x000,                                /* low byte */
132
+  0x000,                                /* height byte */
133
+  U8G_ESC_ADR(1),               /* instruction mode */
134
+  0x024,                                /* set adr pointer */
135
+  
136
+
137
+  U8G_ESC_DLY(100),         /* delay 100 ms */
138
+  
139
+  U8G_ESC_ADR(0),               /* data mode */
140
+  U8G_ESC_CS(0),             /* disable chip */
141
+  U8G_ESC_END                /* end of sequence */
142
+};
143
+
144
+uint8_t u8g_dev_t6963_240x64_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
145
+{
146
+  switch(msg)
147
+  {
148
+    case U8G_DEV_MSG_INIT:
149
+      u8g_InitCom(u8g, dev);    
150
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_t6963_240x64_init_seq);
151
+      break;
152
+    case U8G_DEV_MSG_STOP:
153
+      break;
154
+    case U8G_DEV_MSG_PAGE_NEXT:
155
+      {
156
+        uint8_t y, i;
157
+        uint16_t disp_ram_adr;
158
+        uint8_t *ptr;
159
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
160
+
161
+        
162
+	u8g_SetAddress(u8g, dev, 0);           /* data mode */
163
+        u8g_SetChipSelect(u8g, dev, 1);
164
+        y = pb->p.page_y0;
165
+        ptr = pb->buf;
166
+        disp_ram_adr = WIDTH/8;
167
+        disp_ram_adr *= y;
168
+        for( i = 0; i < PAGE_HEIGHT; i ++ )
169
+        {
170
+          u8g_SetAddress(u8g, dev, 0);           /* data mode */
171
+          u8g_WriteByte(u8g, dev, disp_ram_adr&255 );      /* address low byte */
172
+          u8g_WriteByte(u8g, dev, disp_ram_adr>>8 );      /* address hight byte */
173
+          u8g_SetAddress(u8g, dev, 1);           /* cmd mode */
174
+          u8g_WriteByte(u8g, dev, 0x024 );      /* set adr ptr */
175
+	  
176
+          u8g_WriteSequence(u8g, dev, WIDTH/8, ptr);	
177
+	  
178
+          ptr += WIDTH/8;
179
+          disp_ram_adr += WIDTH/8;
180
+        }
181
+	u8g_SetAddress(u8g, dev, 0);           /* data mode */
182
+        u8g_SetChipSelect(u8g, dev, 0);
183
+      }
184
+      break;
185
+  }
186
+  return u8g_dev_pb16h1_base_fn(u8g, dev, msg, arg);
187
+}
188
+
189
+// U8G_PB_DEV(u8g_dev_t6963_240x64_8bit, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_t6963_240x64_fn, U8G_COM_T6963);
190
+
191
+uint8_t u8g_dev_t6963_240x64_2x_bw_buf[WIDTH/8*PAGE_HEIGHT] U8G_NOCOMMON ; 
192
+u8g_pb_t u8g_dev_t6963_240x64_2x_bw_pb = { {PAGE_HEIGHT, HEIGHT, 0, 0, 0},  WIDTH, u8g_dev_t6963_240x64_2x_bw_buf}; 
193
+u8g_dev_t u8g_dev_t6963_240x64_8bit = { u8g_dev_t6963_240x64_fn, &u8g_dev_t6963_240x64_2x_bw_pb, U8G_COM_T6963 };
194
+
195
+

+ 115
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_tls8204_84x48.c View File

@@ -0,0 +1,115 @@
1
+/*
2
+
3
+  u8g_dev_tls8204_84x48.c
4
+  
5
+  Display: Nokia 84x48
6
+  
7
+  Status: Tested with TLS8204V12 Display by Olimex MOD-LCD3310
8
+  
9
+  Contributed: http://code.google.com/p/u8glib/issues/detail?id=126
10
+
11
+  Universal 8bit Graphics Library
12
+  
13
+  Copyright (c) 2011, olikraus@gmail.com
14
+  All rights reserved.
15
+
16
+  Redistribution and use in source and binary forms, with or without modification, 
17
+  are permitted provided that the following conditions are met:
18
+
19
+  * Redistributions of source code must retain the above copyright notice, this list 
20
+    of conditions and the following disclaimer.
21
+    
22
+  * Redistributions in binary form must reproduce the above copyright notice, this 
23
+    list of conditions and the following disclaimer in the documentation and/or other 
24
+    materials provided with the distribution.
25
+
26
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
27
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
28
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
29
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
30
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
31
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
32
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
33
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
34
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
35
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
36
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
37
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
38
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
39
+  
40
+  
41
+*/
42
+
43
+#include "u8g.h"
44
+
45
+#define WIDTH 84
46
+#define HEIGHT 48
47
+#define PAGE_HEIGHT 8
48
+
49
+
50
+static const uint8_t u8g_dev_tls8204_init_seq[] PROGMEM = {
51
+  U8G_ESC_CS(0),             /* disable chip */
52
+  U8G_ESC_ADR(0),           /* instruction mode */
53
+  U8G_ESC_RST(1),           /* do reset low pulse with (1*16)+2 milliseconds */
54
+  U8G_ESC_CS(1),             /* enable chip */
55
+  0x021,		/* activate chip (PD=0), horizontal increment (V=0), enter extended command set (H=1) */
56
+  0x006,		/* temp. control: b10 = 2 */
57
+  0x04 | !!((66-1)&(1u<<6)),
58
+  0x40 | ((66-2) & ((1u<<6)-1)),
59
+  0x013,		/* bias system 1:48 */
60
+  0x0c0,		/* medium Vop */
61
+  0x020,		/* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
62
+  0x00c,		/* display on, normal operation */
63
+  U8G_ESC_DLY(100),       /* delay 100 ms */
64
+  0x020,		                /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
65
+  0x00d,		                /* display on, invert */
66
+  U8G_ESC_DLY(100),       /* delay 100 ms */
67
+  U8G_ESC_DLY(100),       /* delay 100 ms */
68
+  0x020,		                /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
69
+  0x00c,		                /* display on, normal */
70
+  U8G_ESC_DLY(100),       /* delay 100 ms */
71
+  U8G_ESC_CS(0),             /* disable chip */
72
+  U8G_ESC_END                /* end of sequence */
73
+};
74
+
75
+
76
+uint8_t u8g_dev_tls8204_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
77
+{
78
+  switch(msg)
79
+  {
80
+    case U8G_DEV_MSG_INIT:
81
+      u8g_InitCom(u8g, dev);
82
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_tls8204_init_seq);
83
+      break;
84
+    case U8G_DEV_MSG_STOP:
85
+      break;
86
+    case U8G_DEV_MSG_PAGE_NEXT:
87
+      {
88
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
89
+        u8g_SetAddress(u8g, dev, 0);           /* command mode */
90
+        u8g_SetChipSelect(u8g, dev, 1);
91
+        u8g_WriteByte(u8g, dev, 0x020 );		/* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
92
+        u8g_WriteByte(u8g, dev, 0x080 );                        /* set X address */
93
+        u8g_WriteByte(u8g, dev, 0x040 | pb->p.page); /* set Y address */
94
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
95
+        if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
96
+          return 0;
97
+        u8g_SetChipSelect(u8g, dev, 0);
98
+      }
99
+      break;
100
+    case U8G_DEV_MSG_CONTRAST:
101
+      /* the contrast adjustment does not work, needs to be analysed */
102
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
103
+      u8g_SetChipSelect(u8g, dev, 1);
104
+      u8g_WriteByte(u8g, dev, 0x021);        /* command mode, extended function set */
105
+      u8g_WriteByte(u8g, dev, 0x080 | ( (*(uint8_t *)arg) >> 1 ) );
106
+      u8g_WriteByte(u8g, dev, 0x020);        /* command mode, extended function set */
107
+      u8g_SetChipSelect(u8g, dev, 0);
108
+      return 1;
109
+  }
110
+  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
111
+}
112
+
113
+
114
+U8G_PB_DEV(u8g_dev_tls8204_84x48_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_tls8204_fn, U8G_COM_SW_SPI);
115
+

+ 290
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_uc1610_dogxl160.c View File

@@ -0,0 +1,290 @@
1
+/*
2
+
3
+  u8g_dev_uc1610_dogxl160.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+  
35
+*/
36
+
37
+#include "u8g.h"
38
+
39
+#define WIDTH 160
40
+#define HEIGHT 104
41
+
42
+static const uint8_t u8g_dev_uc1610_dogxl160_init_seq[] PROGMEM = {
43
+  U8G_ESC_CS(0),             /* disable chip */
44
+  U8G_ESC_ADR(0),           /* instruction mode */
45
+  U8G_ESC_RST(1),           /* do reset low pulse with (1*16)+2 milliseconds */
46
+  U8G_ESC_CS(1),             /* enable chip */
47
+  0x0f1,	        /* set display height-1 */
48
+  0x067,		/*  */
49
+  0x0c0,		/* SEG & COM normal */
50
+  0x040,		/* set display start line */
51
+  0x050,		/* */
52
+  0x02b,		/* set panelloading */
53
+  0x0eb,		/* set bias 1/2 */
54
+  0x081,		/* set contrast */
55
+  0x05f,		/* */
56
+  0x089,		/* set auto increment */
57
+  0x0a6,		/* normal pixel mode */
58
+  0x0d3,		/* 0xd3=40% RMS separation for gray levels */
59
+  0x0af,		/* display on */
60
+  U8G_ESC_DLY(100),       /* delay 100 ms */
61
+  0x0a5,		                /* display all points, ST7565, UC1610 */
62
+  U8G_ESC_DLY(100),       /* delay 100 ms */
63
+  U8G_ESC_DLY(100),       /* delay 100 ms */
64
+  0x0a4,		                /* normal display */
65
+  
66
+  
67
+  U8G_ESC_CS(0),             /* disable chip */
68
+  U8G_ESC_END                /* end of sequence */
69
+};
70
+
71
+static const uint8_t u8g_dev_uc1610_dogxl160_data_start[] PROGMEM = {
72
+  U8G_ESC_ADR(0),           /* instruction mode */
73
+  U8G_ESC_CS(1),             /* enable chip */
74
+  0x010,		/* set upper 4 bit of the col adr to 0 */
75
+  0x000,		/* set lower 4 bit of the col adr to 0 */      
76
+  U8G_ESC_END                /* end of sequence */
77
+};
78
+
79
+static uint8_t u8g_dev_1to2(uint8_t n)
80
+{
81
+  register uint8_t a,b,c;
82
+  a = n;
83
+  a &= 1;
84
+  n <<= 1;
85
+  b = n;
86
+  b &= 4;  
87
+  n <<= 1;
88
+  c = n;
89
+  c &= 16;
90
+  n <<= 1;
91
+  n &= 64;
92
+  n |= a;
93
+  n |= b;
94
+  n |= c;
95
+  n |= n << 1;
96
+  return n;
97
+}
98
+
99
+uint8_t u8g_dev_uc1610_dogxl160_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
100
+{
101
+  switch(msg)
102
+  {
103
+    case U8G_DEV_MSG_INIT:
104
+      u8g_InitCom(u8g, dev);
105
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_init_seq);
106
+      break;
107
+    case U8G_DEV_MSG_STOP:
108
+      break;
109
+    case U8G_DEV_MSG_PAGE_NEXT:
110
+      {
111
+        int i;
112
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
113
+        u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);    
114
+        u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page*2) ); /* select current page 1/2 (UC1610) */
115
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
116
+        for( i = 0; i < WIDTH; i++ )
117
+        {
118
+          u8g_WriteByte(u8g, dev, u8g_dev_1to2( ((uint8_t *)(pb->buf))[i] ) );          
119
+        }
120
+
121
+        u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);    
122
+        u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page*2+1) ); /* select current page 2/2 (UC1610) */
123
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
124
+        for( i = 0; i < WIDTH; i++ )
125
+        {
126
+          u8g_WriteByte(u8g, dev, u8g_dev_1to2( ((uint8_t *)(pb->buf))[i] >> 4 ) );          
127
+        }
128
+        
129
+        u8g_SetChipSelect(u8g, dev, 0);
130
+      }
131
+      break;
132
+    case U8G_DEV_MSG_CONTRAST:
133
+      u8g_SetChipSelect(u8g, dev, 1);
134
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
135
+      u8g_WriteByte(u8g, dev, 0x081);
136
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
137
+      u8g_SetChipSelect(u8g, dev, 0);      
138
+      return 1;
139
+  }
140
+  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
141
+}
142
+
143
+uint8_t u8g_dev_uc1610_dogxl160_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
144
+{
145
+  switch(msg)
146
+  {
147
+    case U8G_DEV_MSG_INIT:
148
+      u8g_InitCom(u8g, dev);
149
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_init_seq);
150
+      break;
151
+    case U8G_DEV_MSG_STOP:
152
+      break;
153
+    case U8G_DEV_MSG_PAGE_NEXT:
154
+      {
155
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
156
+        u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);    
157
+        u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page) ); /* select current page (UC1610) */
158
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
159
+        if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
160
+          return 0;
161
+        u8g_SetChipSelect(u8g, dev, 0);
162
+      }
163
+      break;
164
+    case U8G_DEV_MSG_CONTRAST:
165
+      u8g_SetChipSelect(u8g, dev, 1);
166
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
167
+      u8g_WriteByte(u8g, dev, 0x081);
168
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
169
+      u8g_SetChipSelect(u8g, dev, 0);      
170
+      return 1;
171
+  }
172
+  return u8g_dev_pb8v2_base_fn(u8g, dev, msg, arg);
173
+}
174
+
175
+uint8_t u8g_dev_uc1610_dogxl160_2x_bw_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
176
+{
177
+  switch(msg)
178
+  {
179
+    case U8G_DEV_MSG_INIT:
180
+      u8g_InitCom(u8g, dev);
181
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_init_seq);
182
+      break;
183
+    case U8G_DEV_MSG_STOP:
184
+      break;
185
+    case U8G_DEV_MSG_PAGE_NEXT:
186
+      {
187
+        int i;
188
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
189
+        
190
+        u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);    
191
+        u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page*4) ); /* select current page 1/2 (UC1610) */
192
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
193
+        for( i = 0; i < WIDTH; i++ )
194
+        {
195
+          u8g_WriteByte(u8g, dev, u8g_dev_1to2( ((uint8_t *)(pb->buf))[i] ) );          
196
+        }
197
+
198
+        u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);    
199
+        u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page*4+1) ); /* select current page 2/2 (UC1610) */
200
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
201
+        for( i = 0; i < WIDTH; i++ )
202
+        {
203
+          u8g_WriteByte(u8g, dev, u8g_dev_1to2( ((uint8_t *)(pb->buf))[i] >> 4 ) );          
204
+        }
205
+
206
+        u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);    
207
+        u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page*4+2) ); /* select current page 1/2 (UC1610) */
208
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
209
+        for( i = 0; i < WIDTH; i++ )
210
+        {
211
+          u8g_WriteByte(u8g, dev, u8g_dev_1to2( ((uint8_t *)(pb->buf+WIDTH))[i] ) );          
212
+        }
213
+
214
+        u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);    
215
+        u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page*4+3) ); /* select current page 2/2 (UC1610) */
216
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
217
+        for( i = 0; i < WIDTH; i++ )
218
+        {
219
+          u8g_WriteByte(u8g, dev, u8g_dev_1to2( ((uint8_t *)(pb->buf+WIDTH))[i] >> 4 ) );          
220
+        }
221
+        
222
+        u8g_SetChipSelect(u8g, dev, 0);
223
+      }
224
+      break;
225
+    case U8G_DEV_MSG_CONTRAST:
226
+      u8g_SetChipSelect(u8g, dev, 1);
227
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
228
+      u8g_WriteByte(u8g, dev, 0x081);
229
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
230
+      u8g_SetChipSelect(u8g, dev, 0);      
231
+      return 1;
232
+  }
233
+  return u8g_dev_pb16v1_base_fn(u8g, dev, msg, arg);
234
+}
235
+
236
+uint8_t u8g_dev_uc1610_dogxl160_2x_gr_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
237
+{
238
+  switch(msg)
239
+  {
240
+    case U8G_DEV_MSG_INIT:
241
+      u8g_InitCom(u8g, dev);
242
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_init_seq);
243
+      break;
244
+    case U8G_DEV_MSG_STOP:
245
+      break;
246
+    case U8G_DEV_MSG_PAGE_NEXT:
247
+      {
248
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
249
+        
250
+        u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);    
251
+        u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page*2) ); /* select current page (UC1610) */
252
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
253
+        if ( u8g_WriteSequence(u8g, dev, WIDTH, pb->buf) == 0 )
254
+          return 0;
255
+
256
+        u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1610_dogxl160_data_start);    
257
+        u8g_WriteByte(u8g, dev, 0x060 | (pb->p.page*2+1) ); /* select current page (UC1610) */
258
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
259
+        if ( u8g_WriteSequence(u8g, dev, WIDTH, pb->buf+WIDTH) == 0 )
260
+          return 0;
261
+        
262
+        u8g_SetChipSelect(u8g, dev, 0);
263
+      }
264
+      break;
265
+    case U8G_DEV_MSG_CONTRAST:
266
+      u8g_SetChipSelect(u8g, dev, 1);
267
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
268
+      u8g_WriteByte(u8g, dev, 0x081);
269
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 1);
270
+      u8g_SetChipSelect(u8g, dev, 0);      
271
+      return 1;
272
+  }
273
+  return u8g_dev_pb16v2_base_fn(u8g, dev, msg, arg);
274
+}
275
+
276
+U8G_PB_DEV(u8g_dev_uc1610_dogxl160_bw_sw_spi, WIDTH, HEIGHT, 8, u8g_dev_uc1610_dogxl160_bw_fn, U8G_COM_SW_SPI);
277
+U8G_PB_DEV(u8g_dev_uc1610_dogxl160_bw_hw_spi, WIDTH, HEIGHT, 8, u8g_dev_uc1610_dogxl160_bw_fn, U8G_COM_HW_SPI);
278
+
279
+U8G_PB_DEV(u8g_dev_uc1610_dogxl160_gr_sw_spi, WIDTH, HEIGHT, 4, u8g_dev_uc1610_dogxl160_gr_fn, U8G_COM_SW_SPI);
280
+U8G_PB_DEV(u8g_dev_uc1610_dogxl160_gr_hw_spi, WIDTH, HEIGHT, 4, u8g_dev_uc1610_dogxl160_gr_fn, U8G_COM_HW_SPI);
281
+
282
+uint8_t u8g_dev_uc1610_dogxl160_2x_bw_buf[WIDTH*2] U8G_NOCOMMON ; 
283
+u8g_pb_t u8g_dev_uc1610_dogxl160_2x_bw_pb = { {16, HEIGHT, 0, 0, 0},  WIDTH, u8g_dev_uc1610_dogxl160_2x_bw_buf}; 
284
+u8g_dev_t u8g_dev_uc1610_dogxl160_2x_bw_sw_spi = { u8g_dev_uc1610_dogxl160_2x_bw_fn, &u8g_dev_uc1610_dogxl160_2x_bw_pb, U8G_COM_SW_SPI };
285
+u8g_dev_t u8g_dev_uc1610_dogxl160_2x_bw_hw_spi = { u8g_dev_uc1610_dogxl160_2x_bw_fn, &u8g_dev_uc1610_dogxl160_2x_bw_pb, U8G_COM_HW_SPI };
286
+
287
+uint8_t u8g_dev_uc1610_dogxl160_2x_gr_buf[WIDTH*2] U8G_NOCOMMON ; 
288
+u8g_pb_t u8g_dev_uc1610_dogxl160_2x_gr_pb = { {8, HEIGHT, 0, 0, 0},  WIDTH, u8g_dev_uc1610_dogxl160_2x_gr_buf}; 
289
+u8g_dev_t u8g_dev_uc1610_dogxl160_2x_gr_sw_spi = { u8g_dev_uc1610_dogxl160_2x_gr_fn, &u8g_dev_uc1610_dogxl160_2x_gr_pb, U8G_COM_SW_SPI };
290
+u8g_dev_t u8g_dev_uc1610_dogxl160_2x_gr_hw_spi = { u8g_dev_uc1610_dogxl160_2x_gr_fn, &u8g_dev_uc1610_dogxl160_2x_gr_pb, U8G_COM_HW_SPI };

+ 113
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_uc1701_dogs102.c View File

@@ -0,0 +1,113 @@
1
+/*
2
+
3
+  u8g_dev_uc1701_dogs102.c
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+  
35
+*/
36
+
37
+#include "u8g.h"
38
+
39
+#define WIDTH 102
40
+#define HEIGHT 64
41
+#define PAGE_HEIGHT 8
42
+
43
+static const uint8_t u8g_dev_dogs102_init_seq[] PROGMEM = {
44
+  U8G_ESC_CS(0),             /* disable chip */
45
+  U8G_ESC_ADR(0),           /* instruction mode */
46
+  U8G_ESC_RST(1),           /* do reset low pulse with (1*16)+2 milliseconds */
47
+  U8G_ESC_CS(1),             /* enable chip */
48
+  0x040,		                /* set display start line to 0 */
49
+  0x0a1,		                /* ADC set to reverse */
50
+  0x0c0,		                /* common output mode */
51
+  0x0a6,		                /* display normal, bit val 0: LCD pixel off. */
52
+  0x0a2,		                /* LCD bias 1/9 */
53
+  0x02f,		                /* all power  control circuits on */
54
+  0x027,		                /* regulator, booster and follower */
55
+  0x081,		                /* set contrast */
56
+  0x00e,		                /* contrast value, EA default: 0x010, previous value for S102: 0x0e */
57
+  0x0fa,		                /* Set Temp compensation */ 
58
+  0x090,		                /* 0.11 deg/c WP Off WC Off*/
59
+  0x0a4,		                /* normal display  */
60
+  0x0af,		                /* display on */
61
+  U8G_ESC_DLY(100),       /* delay 100 ms */
62
+  0x0a5,		                /* display all points, ST7565, UC1610 */
63
+  U8G_ESC_DLY(100),       /* delay 100 ms */
64
+  U8G_ESC_DLY(100),       /* delay 100 ms */
65
+  0x0a4,		                /* normal display */
66
+  U8G_ESC_CS(0),             /* disable chip */
67
+  U8G_ESC_END                /* end of sequence */
68
+};
69
+
70
+static const uint8_t u8g_dev_dogs102_data_start[] PROGMEM = {
71
+  U8G_ESC_ADR(0),           /* instruction mode */
72
+  U8G_ESC_CS(1),             /* enable chip */
73
+  0x010,		/* set upper 4 bit of the col adr to 0 */
74
+  0x000,		/* set lower 4 bit of the col adr to 0 */      
75
+  U8G_ESC_END                /* end of sequence */
76
+};
77
+
78
+uint8_t u8g_dev_dogs102_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
79
+{
80
+  switch(msg)
81
+  {
82
+    case U8G_DEV_MSG_INIT:
83
+      u8g_InitCom(u8g, dev);
84
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_dogs102_init_seq);
85
+      break;
86
+    case U8G_DEV_MSG_STOP:
87
+      break;
88
+    case U8G_DEV_MSG_PAGE_NEXT:
89
+      {
90
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
91
+        u8g_WriteEscSeqP(u8g, dev, u8g_dev_dogs102_data_start);    
92
+        u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page (ST7565R) */
93
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
94
+        if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
95
+          return 0;
96
+        u8g_SetChipSelect(u8g, dev, 0);
97
+      }
98
+      break;
99
+    case U8G_DEV_MSG_CONTRAST:
100
+      u8g_SetChipSelect(u8g, dev, 1);
101
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
102
+      u8g_WriteByte(u8g, dev, 0x081);
103
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
104
+      u8g_SetChipSelect(u8g, dev, 0);      
105
+      return 1;
106
+  }
107
+  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
108
+}
109
+
110
+U8G_PB_DEV(u8g_dev_uc1701_dogs102_sw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_dogs102_fn, U8G_COM_SW_SPI);
111
+U8G_PB_DEV(u8g_dev_uc1701_dogs102_hw_spi , WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_dogs102_fn, U8G_COM_HW_SPI);
112
+
113
+

+ 114
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_uc1701_mini12864.c View File

@@ -0,0 +1,114 @@
1
+/*
2
+
3
+  u8g_dev_uc1701_mini12864.c (dealextreme)
4
+
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2011, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+  
35
+*/
36
+
37
+#include "u8g.h"
38
+
39
+#define WIDTH 128
40
+#define HEIGHT 64
41
+#define PAGE_HEIGHT 8
42
+
43
+static const uint8_t u8g_dev_uc1701_mini12864_init_seq[] PROGMEM = {
44
+  U8G_ESC_CS(0),             /* disable chip */
45
+  U8G_ESC_ADR(0),           /* instruction mode */
46
+  U8G_ESC_RST(1),           /* do reset low pulse with (1*16)+2 milliseconds */
47
+  U8G_ESC_CS(1),             /* enable chip */
48
+
49
+  0x040,		/* set display start line to 0 */
50
+  0x0a0,		/* ADC set to reverse */
51
+  0x0c8,		/* common output mode */
52
+  0x0a6,		/* display normal, bit val 0: LCD pixel off. */
53
+  0x0a2,		/* LCD bias 1/9 */
54
+  0x02f,		/* all power  control circuits on */
55
+  0x0f8,		/* set booster ratio to */
56
+  0x000,		/* 4x */
57
+  0x023,		/* set V0 voltage resistor ratio to large */
58
+  0x081,		/* set contrast */
59
+  0x027,		/* contrast value */
60
+  0x0ac,		/* indicator */
61
+  0x000,		/* disable */
62
+  0x0af,		/* display on */
63
+
64
+  U8G_ESC_DLY(100),       /* delay 100 ms */
65
+  0x0a5,		                /* display all points, ST7565 */
66
+  U8G_ESC_DLY(100),       /* delay 100 ms */
67
+  U8G_ESC_DLY(100),       /* delay 100 ms */
68
+  0x0a4,		                /* normal display */
69
+  U8G_ESC_CS(0),             /* disable chip */
70
+  U8G_ESC_END                /* end of sequence */
71
+};
72
+
73
+static const uint8_t u8g_dev_uc1701_mini12864_data_start[] PROGMEM = {
74
+  U8G_ESC_ADR(0),           /* instruction mode */
75
+  U8G_ESC_CS(1),             /* enable chip */
76
+  0x010,		/* set upper 4 bit of the col adr to 0 */
77
+  0x000,		/* set lower 4 bit of the col adr to 4  */
78
+  U8G_ESC_END                /* end of sequence */
79
+};
80
+
81
+uint8_t u8g_dev_uc1701_mini12864_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
82
+{
83
+  switch(msg)
84
+  {
85
+    case U8G_DEV_MSG_INIT:
86
+      u8g_InitCom(u8g, dev);
87
+      u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_init_seq);
88
+      break;
89
+    case U8G_DEV_MSG_STOP:
90
+      break;
91
+    case U8G_DEV_MSG_PAGE_NEXT:
92
+      {
93
+        u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
94
+        u8g_WriteEscSeqP(u8g, dev, u8g_dev_uc1701_mini12864_data_start);    
95
+        u8g_WriteByte(u8g, dev, 0x0b0 | pb->p.page); /* select current page */
96
+        u8g_SetAddress(u8g, dev, 1);           /* data mode */
97
+        if ( u8g_pb_WriteBuffer(pb, u8g, dev) == 0 )
98
+          return 0;
99
+        u8g_SetChipSelect(u8g, dev, 0);
100
+      }
101
+      break;
102
+    case U8G_DEV_MSG_CONTRAST:
103
+      u8g_SetChipSelect(u8g, dev, 1);
104
+      u8g_SetAddress(u8g, dev, 0);          /* instruction mode */
105
+      u8g_WriteByte(u8g, dev, 0x081);
106
+      u8g_WriteByte(u8g, dev, (*(uint8_t *)arg) >> 2);
107
+      u8g_SetChipSelect(u8g, dev, 0);      
108
+      return 1;
109
+  }
110
+  return u8g_dev_pb8v1_base_fn(u8g, dev, msg, arg);
111
+}
112
+
113
+U8G_PB_DEV(u8g_dev_uc1701_mini12864_sw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1701_mini12864_fn, U8G_COM_SW_SPI);
114
+U8G_PB_DEV(u8g_dev_uc1701_mini12864_hw_spi, WIDTH, HEIGHT, PAGE_HEIGHT, u8g_dev_uc1701_mini12864_fn, U8G_COM_HW_SPI);

+ 100
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_ellipse.c View File

@@ -0,0 +1,100 @@
1
+/*
2
+
3
+  u8g_ellipse.c
4
+
5
+  Utility to draw empty and filled ellipses.
6
+  
7
+  Universal 8bit Graphics Library
8
+  
9
+  Copyright (c) 2011, bjthom@gmail.com
10
+  All rights reserved.
11
+
12
+  Redistribution and use in source and binary forms, with or without modification, 
13
+  are permitted provided that the following conditions are met:
14
+
15
+  * Redistributions of source code must retain the above copyright notice, this list 
16
+    of conditions and the following disclaimer.
17
+    
18
+  * Redistributions in binary form must reproduce the above copyright notice, this 
19
+    list of conditions and the following disclaimer in the documentation and/or other 
20
+    materials provided with the distribution.
21
+
22
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
23
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
24
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
25
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
26
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
27
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
28
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
29
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
30
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
31
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
32
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
33
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
34
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
35
+  
36
+  Addition to the U8G Library as of 02/29/12
37
+  Adapted from Bresenham's Algorithm and the following websites:
38
+	http://free.pages.at/easyfilter/bresenham.html
39
+	http://homepage.smc.edu/kennedy_john/belipse.pdf
40
+  
41
+*/
42
+
43
+#include "u8g.h"
44
+
45
+
46
+#ifdef WORK_IN_PROGRESS
47
+
48
+void u8g_DrawEllipseRect(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t x1, u8g_uint_t y1)
49
+{
50
+	int a = abs(x1 - x0);
51
+	int b = abs(y1 - y0);	//get diameters
52
+	int b1 = b&1;
53
+	long dx = 4*(1-a)*b*b;
54
+	long dy = 4*(b1+1)*a*a;
55
+	long err = dx+dy+b1*a*a;
56
+	long e2;
57
+	
58
+	if (x0 > x1) { x0 = x1; x1 += a; }
59
+	if (y0 > y1) { y0 = y1; } 
60
+	y0 += (b+1)/2;
61
+	y1 = y0-b1;
62
+	a *= 8*a;
63
+	b1 = 8*b*b;
64
+	
65
+	do {
66
+		u8g_DrawPixel(u8g, x1, y0);
67
+		u8g_DrawPixel(u8g, x0, y0);
68
+		u8g_DrawPixel(u8g, x0, y1);
69
+		u8g_DrawPixel(u8g, x1, y1);
70
+		e2 = 2*err;
71
+		if (e2 >= dx) {
72
+			x0++;
73
+			x1--;
74
+			err += dx += b1;
75
+		}
76
+		if (e2 <= dy) {
77
+			y0++;
78
+			y1--;
79
+			err += dy += a;
80
+		}
81
+	} while (x0 <= x1);
82
+	
83
+	while (y0-y1 < b) {
84
+		u8g_DrawPixel(u8g, x0-1, y0);
85
+		u8g_DrawPixel(u8g, x1+1, y0++);
86
+		u8g_DrawPixel(u8g, x0-1, y1);
87
+		u8g_DrawPixel(u8g, x1+1, y1--);
88
+	}
89
+}
90
+
91
+void u8g_DrawEllipse(u8g_t *u8g, u8g_uint_t x0, u8g_uint_t y0, u8g_uint_t xr, u8g_uint_t yr)
92
+{
93
+	u8g_DrawPixel(u8g, x0, y0+yr);
94
+	u8g_DrawPixel(u8g, x0, y0-yr);
95
+	u8g_DrawPixel(u8g, x0+xr, y0);
96
+	u8g_DrawPixel(u8g, x0-xr, y0);
97
+}
98
+
99
+#endif
100
+

+ 1422
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_font.c
File diff suppressed because it is too large
View File


+ 84486
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_font_data.c
File diff suppressed because it is too large
View File


+ 81
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_line.c View File

@@ -0,0 +1,81 @@
1
+/*
2
+
3
+  u8g_line.h
4
+  
5
+  Universal 8bit Graphics Library
6
+  
7
+  Copyright (c) 2012, olikraus@gmail.com
8
+  All rights reserved.
9
+
10
+  Redistribution and use in source and binary forms, with or without modification, 
11
+  are permitted provided that the following conditions are met:
12
+
13
+  * Redistributions of source code must retain the above copyright notice, this list 
14
+    of conditions and the following disclaimer.
15
+    
16
+  * Redistributions in binary form must reproduce the above copyright notice, this 
17
+    list of conditions and the following disclaimer in the documentation and/or other 
18
+    materials provided with the distribution.
19
+
20
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
21
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
22
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
23
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
24
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
25
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
26
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
27
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
30
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
31
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
32
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
33
+  
34
+*/
35
+
36
+#include "u8g.h"
37
+
38
+void u8g_DrawLine(u8g_t *u8g, u8g_uint_t x1, u8g_uint_t y1, u8g_uint_t x2, u8g_uint_t y2)
39
+{
40
+  u8g_uint_t tmp;
41
+  u8g_uint_t x,y;
42
+  u8g_uint_t dx, dy;
43
+  u8g_int_t err;
44
+  u8g_int_t ystep;
45
+
46
+  uint8_t swapxy = 0;
47
+  
48
+  /* no BBX intersection check at the moment, should be added... */
49
+
50
+  if ( x1 > x2 ) dx = x1-x2; else dx = x2-x1;
51
+  if ( y1 > y2 ) dy = y1-y2; else dy = y2-y1;
52
+
53
+  if ( dy > dx ) 
54
+  {
55
+    swapxy = 1;
56
+    tmp = dx; dx =dy; dy = tmp;
57
+    tmp = x1; x1 =y1; y1 = tmp;
58
+    tmp = x2; x2 =y2; y2 = tmp;
59
+  }
60
+  if ( x1 > x2 ) 
61
+  {
62
+    tmp = x1; x1 =x2; x2 = tmp;
63
+    tmp = y1; y1 =y2; y2 = tmp;
64
+  }
65
+  err = dx >> 1;
66
+  if ( y2 > y1 ) ystep = 1; else ystep = -1;
67
+  y = y1;
68
+  for( x = x1; x <= x2; x++ )
69
+  {
70
+    if ( swapxy == 0 ) 
71
+      u8g_DrawPixel(u8g, x, y); 
72
+    else 
73
+      u8g_DrawPixel(u8g, y, x); 
74
+    err -= (uint8_t)dy;
75
+    if ( err < 0 ) 
76
+    {
77
+      y += (u8g_uint_t)ystep;
78
+      err += (u8g_uint_t)dx;
79
+    }
80
+  }
81
+}

+ 456
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_ll_api.c View File

@@ -0,0 +1,456 @@
1
+/*
2
+
3
+  u8g_ll_api.c
4
+  
5
+  low level api
6
+
7
+  Universal 8bit Graphics Library
8
+  
9
+  Copyright (c) 2011, olikraus@gmail.com
10
+  All rights reserved.
11
+
12
+  Redistribution and use in source and binary forms, with or without modification, 
13
+  are permitted provided that the following conditions are met:
14
+
15
+  * Redistributions of source code must retain the above copyright notice, this list 
16
+    of conditions and the following disclaimer.
17
+    
18
+  * Redistributions in binary form must reproduce the above copyright notice, this 
19
+    list of conditions and the following disclaimer in the documentation and/or other 
20
+    materials provided with the distribution.
21
+
22
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
23
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
24
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
25
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
26
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
27
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
28
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
29
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
30
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
31
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
32
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
33
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
34
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
35
+  
36
+
37
+*/
38
+
39
+#include <stddef.h>
40
+#include "u8g.h"
41
+
42
+uint8_t u8g_call_dev_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
43
+{
44
+  return dev->dev_fn(u8g, dev, msg, arg); 
45
+}
46
+
47
+/*====================================================================*/
48
+
49
+uint8_t u8g_InitLL(u8g_t *u8g, u8g_dev_t *dev)
50
+{
51
+  uint8_t r;
52
+  u8g->state_cb(U8G_STATE_MSG_BACKUP_ENV);
53
+  r =  u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_INIT, NULL);
54
+  u8g->state_cb(U8G_STATE_MSG_BACKUP_U8G);
55
+  u8g->state_cb(U8G_STATE_MSG_RESTORE_ENV);
56
+  return r;
57
+}
58
+
59
+void u8g_FirstPageLL(u8g_t *u8g, u8g_dev_t *dev)
60
+{  
61
+  u8g->state_cb(U8G_STATE_MSG_BACKUP_ENV);
62
+  u8g->state_cb(U8G_STATE_MSG_RESTORE_U8G);
63
+  u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_PAGE_FIRST, NULL);
64
+  u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_PAGE_BOX, &(u8g->current_page));
65
+  u8g->state_cb(U8G_STATE_MSG_RESTORE_ENV);
66
+}
67
+
68
+uint8_t u8g_NextPageLL(u8g_t *u8g, u8g_dev_t *dev)
69
+{  
70
+  uint8_t r;
71
+  u8g->state_cb(U8G_STATE_MSG_BACKUP_ENV);
72
+  u8g->state_cb(U8G_STATE_MSG_RESTORE_U8G);
73
+  r = u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_PAGE_NEXT, NULL);
74
+  if ( r != 0 )
75
+  {
76
+    u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_PAGE_BOX, &(u8g->current_page));
77
+  }
78
+  u8g->state_cb(U8G_STATE_MSG_RESTORE_ENV);
79
+  return r;
80
+}
81
+
82
+uint8_t u8g_SetContrastLL(u8g_t *u8g, u8g_dev_t *dev, uint8_t contrast)
83
+{  
84
+  return u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_CONTRAST, &contrast);
85
+}
86
+
87
+void u8g_DrawPixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y)
88
+{
89
+  u8g_dev_arg_pixel_t *arg = &(u8g->arg_pixel);
90
+  arg->x = x;
91
+  arg->y = y;
92
+  u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_SET_PIXEL, arg);
93
+}
94
+
95
+void u8g_Draw8PixelLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel)
96
+{
97
+  u8g_dev_arg_pixel_t *arg = &(u8g->arg_pixel);
98
+  arg->x = x;
99
+  arg->y = y;
100
+  arg->dir = dir;
101
+  arg->pixel = pixel;
102
+  u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_SET_8PIXEL, arg);
103
+}
104
+
105
+#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
106
+uint8_t u8g_IsBBXIntersectionLL(u8g_t *u8g, u8g_dev_t *dev, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
107
+{  
108
+  return u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_IS_BBX_INTERSECTION, &arg);
109
+}
110
+#endif
111
+
112
+
113
+
114
+u8g_uint_t u8g_GetWidthLL(u8g_t *u8g, u8g_dev_t *dev)
115
+{
116
+  u8g_uint_t r;
117
+  u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_WIDTH, &r);
118
+  return r;
119
+}
120
+
121
+u8g_uint_t u8g_GetHeightLL(u8g_t *u8g, u8g_dev_t *dev)
122
+{       
123
+  u8g_uint_t r;
124
+  u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_HEIGHT, &r);
125
+  return r;
126
+}
127
+
128
+u8g_uint_t u8g_GetModeLL(u8g_t *u8g, u8g_dev_t *dev)
129
+{       
130
+  return u8g_call_dev_fn(u8g, dev, U8G_DEV_MSG_GET_MODE, NULL);
131
+}
132
+
133
+
134
+
135
+/*====================================================================*/
136
+
137
+void u8g_UpdateDimension(u8g_t *u8g)
138
+{
139
+  u8g->width = u8g_GetWidthLL(u8g, u8g->dev);
140
+  u8g->height = u8g_GetHeightLL(u8g, u8g->dev);
141
+  u8g->mode = u8g_GetModeLL(u8g, u8g->dev);
142
+  /* 9 Dec 2012: u8g_scale.c requires update of current page */
143
+  u8g_call_dev_fn(u8g, u8g->dev, U8G_DEV_MSG_GET_PAGE_BOX, &(u8g->current_page));
144
+}
145
+
146
+static void u8g_init_data(u8g_t *u8g)
147
+{
148
+  uint8_t i;
149
+  u8g->font = NULL;
150
+  u8g->cursor_font = NULL;
151
+  u8g->cursor_bg_color = 0;
152
+  u8g->cursor_fg_color = 1;
153
+  u8g->cursor_encoding = 34;
154
+  u8g->cursor_fn = (u8g_draw_cursor_fn)0;
155
+  
156
+  for( i = 0; i < U8G_PIN_LIST_LEN; i++ )
157
+    u8g->pin_list[i] = U8G_PIN_NONE;
158
+
159
+  u8g_SetColorIndex(u8g, 1);
160
+
161
+  u8g_SetFontPosBaseline(u8g);
162
+  
163
+  u8g->font_height_mode = U8G_FONT_HEIGHT_MODE_XTEXT;
164
+  u8g->font_ref_ascent = 0;
165
+  u8g->font_ref_descent = 0;
166
+  u8g->font_line_spacing_factor = 64;           /* 64 = 1.0, 77 = 1.2 line spacing factor */
167
+  u8g->line_spacing = 0;
168
+  
169
+  u8g->state_cb = u8g_state_dummy_cb;
170
+
171
+}
172
+
173
+uint8_t u8g_Begin(u8g_t *u8g)
174
+{
175
+  /* call and init low level driver and com device */
176
+  if ( u8g_InitLL(u8g, u8g->dev) == 0 )
177
+    return 0;
178
+  /* fetch width and height from the low level */
179
+  u8g_UpdateDimension(u8g);
180
+  return 1;
181
+}
182
+
183
+uint8_t u8g_Init(u8g_t *u8g, u8g_dev_t *dev)
184
+{
185
+  u8g_init_data(u8g);
186
+  u8g->dev = dev;
187
+  
188
+  /* On the Arduino Environment this will lead to two calls to u8g_Begin(), the following line will be called first (by U8glib constructors) */
189
+  /* if - in future releases - this is removed, then still call u8g_UpdateDimension() */
190
+  /* if Arduino call u8g_UpdateDimension else u8g_Begin */
191
+  /* issue 146 */
192
+  return u8g_Begin(u8g);
193
+}
194
+
195
+uint8_t u8g_InitSPI(u8g_t *u8g, u8g_dev_t *dev, uint8_t sck, uint8_t mosi, uint8_t cs, uint8_t a0, uint8_t reset)
196
+{
197
+  
198
+  /* fill data structure with some suitable values */
199
+  u8g_init_data(u8g);
200
+  u8g->dev = dev;
201
+    
202
+  /* assign user pins */
203
+  u8g->pin_list[U8G_PI_SCK] = sck;
204
+  u8g->pin_list[U8G_PI_MOSI] = mosi;
205
+  u8g->pin_list[U8G_PI_CS] = cs;
206
+  u8g->pin_list[U8G_PI_A0] = a0;
207
+  u8g->pin_list[U8G_PI_RESET] = reset;
208
+  
209
+  /* On the Arduino Environment this will lead to two calls to u8g_Begin(), the following line will be called first (by U8glib constructors) */
210
+  /* if - in future releases - this is removed, then still call u8g_UpdateDimension() */
211
+  /* if Arduino call u8g_UpdateDimension else u8g_Begin */
212
+  /* issue 146 */
213
+  return u8g_Begin(u8g);
214
+}
215
+
216
+uint8_t u8g_InitHWSPI(u8g_t *u8g, u8g_dev_t *dev, uint8_t cs, uint8_t a0, uint8_t reset)
217
+{
218
+  /* fill data structure with some suitable values */
219
+  u8g_init_data(u8g);
220
+  u8g->dev = dev;
221
+  
222
+  
223
+  /* assign user pins */
224
+  u8g->pin_list[U8G_PI_CS] = cs;
225
+  u8g->pin_list[U8G_PI_A0] = a0;
226
+  u8g->pin_list[U8G_PI_RESET] = reset;
227
+  
228
+  return u8g_Begin(u8g);
229
+}
230
+
231
+uint8_t u8g_InitI2C(u8g_t *u8g, u8g_dev_t *dev, uint8_t options)
232
+{
233
+  /* fill data structure with some suitable values */
234
+  u8g_init_data(u8g);
235
+  u8g->dev = dev;
236
+    
237
+  u8g->pin_list[U8G_PI_I2C_OPTION] = options;
238
+  
239
+  return u8g_Begin(u8g);
240
+}
241
+
242
+
243
+uint8_t u8g_Init8BitFixedPort(u8g_t *u8g, u8g_dev_t *dev, uint8_t en, uint8_t cs, uint8_t di, uint8_t rw, uint8_t reset)
244
+{
245
+  
246
+  /* fill data structure with some suitable values */
247
+  u8g_init_data(u8g);
248
+  u8g->dev = dev;
249
+    
250
+  /* assign user pins */
251
+
252
+  u8g->pin_list[U8G_PI_EN] = en;
253
+  u8g->pin_list[U8G_PI_CS] = cs;
254
+  u8g->pin_list[U8G_PI_DI] = di;
255
+  u8g->pin_list[U8G_PI_RW] = rw;
256
+  u8g->pin_list[U8G_PI_RESET] = reset;
257
+
258
+  return u8g_Begin(u8g);
259
+}
260
+
261
+uint8_t u8g_Init8Bit(u8g_t *u8g, u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
262
+  uint8_t en, uint8_t cs1, uint8_t cs2, uint8_t di, uint8_t rw, uint8_t reset)
263
+{
264
+  
265
+  /* fill data structure with some suitable values */
266
+  u8g_init_data(u8g);
267
+  u8g->dev = dev;
268
+    
269
+  /* assign user pins */
270
+
271
+  u8g->pin_list[U8G_PI_D0] = d0;
272
+  u8g->pin_list[U8G_PI_D1] = d1;
273
+  u8g->pin_list[U8G_PI_D2] = d2;
274
+  u8g->pin_list[U8G_PI_D3] = d3;
275
+  u8g->pin_list[U8G_PI_D4] = d4;
276
+  u8g->pin_list[U8G_PI_D5] = d5;
277
+  u8g->pin_list[U8G_PI_D6] = d6;
278
+  u8g->pin_list[U8G_PI_D7] = d7;
279
+
280
+  u8g->pin_list[U8G_PI_EN] = en;
281
+  u8g->pin_list[U8G_PI_CS1] = cs1;
282
+  u8g->pin_list[U8G_PI_CS2] = cs2;
283
+  u8g->pin_list[U8G_PI_DI] = di;
284
+  u8g->pin_list[U8G_PI_RW] = rw;
285
+  u8g->pin_list[U8G_PI_RESET] = reset;
286
+  
287
+  return u8g_Begin(u8g);
288
+}
289
+
290
+/*
291
+
292
+  PIN_D0 8
293
+  PIN_D1 9
294
+  PIN_D2 10
295
+  PIN_D3 11
296
+  PIN_D4 4
297
+  PIN_D5 5
298
+  PIN_D6 6
299
+  PIN_D7 7
300
+
301
+  PIN_CS 14
302
+  PIN_A0 15
303
+  PIN_RESET 16
304
+  PIN_WR 17
305
+  PIN_RD 18
306
+  
307
+  u8g_InitRW8Bit(u8g, dev, d0, d1, d2, d3, d4, d5, d6, d7, cs, a0, wr, rd, reset)
308
+  u8g_InitRW8Bit(u8g, dev,  8,  9, 10, 11,  4,  5,  6,  7, 14, 15, 17, 18, 16)
309
+
310
+*/
311
+
312
+uint8_t u8g_InitRW8Bit(u8g_t *u8g, u8g_dev_t *dev, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7, 
313
+  uint8_t cs, uint8_t a0, uint8_t wr, uint8_t rd, uint8_t reset)
314
+{
315
+  
316
+  /* fill data structure with some suitable values */
317
+  u8g_init_data(u8g);
318
+  u8g->dev = dev;
319
+    
320
+  /* assign user pins */
321
+
322
+  u8g->pin_list[U8G_PI_D0] = d0;
323
+  u8g->pin_list[U8G_PI_D1] = d1;
324
+  u8g->pin_list[U8G_PI_D2] = d2;
325
+  u8g->pin_list[U8G_PI_D3] = d3;
326
+  u8g->pin_list[U8G_PI_D4] = d4;
327
+  u8g->pin_list[U8G_PI_D5] = d5;
328
+  u8g->pin_list[U8G_PI_D6] = d6;
329
+  u8g->pin_list[U8G_PI_D7] = d7;
330
+
331
+  u8g->pin_list[U8G_PI_CS] = cs;
332
+  u8g->pin_list[U8G_PI_A0] = a0;
333
+  u8g->pin_list[U8G_PI_WR] = wr;
334
+  u8g->pin_list[U8G_PI_RD] = rd;
335
+  u8g->pin_list[U8G_PI_RESET] = reset;
336
+  
337
+  return u8g_Begin(u8g);
338
+}
339
+
340
+void u8g_FirstPage(u8g_t *u8g)
341
+{
342
+  u8g_FirstPageLL(u8g, u8g->dev);
343
+}
344
+
345
+uint8_t u8g_NextPage(u8g_t *u8g)
346
+{
347
+  if  ( u8g->cursor_fn != (u8g_draw_cursor_fn)0 )
348
+  {
349
+    u8g->cursor_fn(u8g);
350
+  }
351
+  return u8g_NextPageLL(u8g, u8g->dev);
352
+}
353
+
354
+uint8_t u8g_SetContrast(u8g_t *u8g, uint8_t contrast)
355
+{
356
+  return u8g_SetContrastLL(u8g, u8g->dev, contrast);
357
+}
358
+
359
+void u8g_SleepOn(u8g_t *u8g)
360
+{
361
+  u8g_call_dev_fn(u8g, u8g->dev, U8G_DEV_MSG_SLEEP_ON, NULL);
362
+}
363
+
364
+void u8g_SleepOff(u8g_t *u8g)
365
+{
366
+  u8g_call_dev_fn(u8g, u8g->dev, U8G_DEV_MSG_SLEEP_OFF, NULL);
367
+}
368
+
369
+
370
+void u8g_DrawPixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y)
371
+{
372
+  u8g_DrawPixelLL(u8g, u8g->dev, x, y);
373
+}
374
+
375
+void u8g_Draw8Pixel(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, uint8_t dir, uint8_t pixel)
376
+{
377
+  u8g_Draw8PixelLL(u8g, u8g->dev, x, y, dir, pixel);
378
+}
379
+
380
+/* u8g_IsBBXIntersection() has been moved to u8g_clip.c */
381
+#ifdef OBSOLETE_CODE
382
+uint8_t u8g_IsBBXIntersection(u8g_t *u8g, u8g_uint_t x, u8g_uint_t y, u8g_uint_t w, u8g_uint_t h)
383
+{
384
+  /* new code */
385
+  u8g_dev_arg_bbx_t arg;
386
+  arg.x = x;
387
+  arg.y = y;
388
+  arg.w = w;
389
+  arg.h = h;
390
+  return u8g_is_box_bbx_intersection(&(u8g->current_page), &arg);
391
+
392
+  /* old code */
393
+  //return u8g_IsBBXIntersectionLL(u8g, u8g->dev, x, y, w, h);
394
+}
395
+#endif
396
+
397
+void u8g_SetColorIndex(u8g_t *u8g, uint8_t idx)
398
+{
399
+  u8g->arg_pixel.color = idx;
400
+  /*u8g->color_index = idx; */ /* must be removed */
401
+}
402
+
403
+uint8_t u8g_GetColorIndex(u8g_t *u8g)
404
+{
405
+  return u8g->arg_pixel.color;
406
+}
407
+
408
+uint8_t u8g_GetDefaultForegroundColor(u8g_t *u8g)
409
+{
410
+  uint8_t mode;
411
+  mode = u8g_GetMode(u8g);
412
+  if ( mode == U8G_MODE_R3G3B2 ) 
413
+    return 255;     /* white */
414
+  else if ( u8g_GetMode(u8g) == U8G_MODE_GRAY2BIT )
415
+    return 3;         /* max intensity */
416
+  else /* if ( u8g.getMode() == U8G_MODE_BW ) */
417
+    return 1;         /* pixel on */
418
+  return 1;
419
+}
420
+
421
+void u8g_SetDefaultForegroundColor(u8g_t *u8g)
422
+{
423
+  u8g_SetColorIndex(u8g, u8g_GetDefaultForegroundColor(u8g));
424
+}
425
+
426
+uint8_t u8g_GetDefaultBackgroundColor(u8g_t *u8g)
427
+{
428
+  return 0;
429
+}
430
+
431
+void u8g_SetDefaultBackgroundColor(u8g_t *u8g)
432
+{
433
+  u8g_SetColorIndex(u8g, u8g_GetDefaultBackgroundColor(u8g));         /* pixel on / black */
434
+}
435
+
436
+uint8_t u8g_GetDefaultMidColor(u8g_t *u8g)
437
+{
438
+  uint8_t mode;
439
+  mode = u8g_GetMode(u8g);
440
+  if ( mode == U8G_MODE_R3G3B2 ) 
441
+    return 0x06d;     /* gray: 01101101 */
442
+  else if ( u8g_GetMode(u8g) == U8G_MODE_GRAY2BIT )
443
+    return 1;         /* low mid intensity */
444
+  else /* if ( u8g.getMode() == U8G_MODE_BW ) */
445
+    return 1;         /* pixel on */
446
+  return 1;   /* default */
447
+}
448
+
449
+void u8g_SetDefaultMidColor(u8g_t *u8g)
450
+{
451
+  u8g_SetColorIndex(u8g, u8g_GetDefaultMidColor(u8g));
452
+}
453
+
454
+
455
+
456
+

+ 81
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_page.c View File

@@ -0,0 +1,81 @@
1
+/*
2
+
3
+  u8g_page.c
4
+  
5
+  page helper functions, only called by the dev handler.
6
+
7
+  Universal 8bit Graphics Library
8
+  
9
+  Copyright (c) 2011, olikraus@gmail.com
10
+  All rights reserved.
11
+
12
+  Redistribution and use in source and binary forms, with or without modification, 
13
+  are permitted provided that the following conditions are met:
14
+
15
+  * Redistributions of source code must retain the above copyright notice, this list 
16
+    of conditions and the following disclaimer.
17
+    
18
+  * Redistributions in binary form must reproduce the above copyright notice, this 
19
+    list of conditions and the following disclaimer in the documentation and/or other 
20
+    materials provided with the distribution.
21
+
22
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
23
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
24
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
25
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
26
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
27
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
28
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
29
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
30
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
31
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
32
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
33
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
34
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
35
+  
36
+  
37
+*/
38
+
39
+#include "u8g.h"
40
+
41
+/*
42
+  setup page count structure
43
+  conditions: page_height <= total_height
44
+*/
45
+void u8g_page_Init(u8g_page_t *p, u8g_uint_t page_height, u8g_uint_t total_height )
46
+{
47
+  p->page_height = page_height;
48
+  p->total_height = total_height;
49
+  p->page = 0;
50
+  u8g_page_First(p);
51
+}
52
+
53
+void u8g_page_First(u8g_page_t *p)
54
+{
55
+  p->page_y0 = 0;
56
+  p->page_y1 = p->page_height;
57
+  p->page_y1--;
58
+  p->page = 0;
59
+}
60
+
61
+uint8_t u8g_page_Next(u8g_page_t * p)
62
+{
63
+  register u8g_uint_t y1;
64
+  p->page_y0 += p->page_height;
65
+  if ( p->page_y0 >= p->total_height )
66
+    return 0;
67
+  p->page++;
68
+  y1 = p->page_y1;
69
+  y1 += p->page_height;
70
+  if ( y1 >= p->total_height )
71
+  {
72
+    y1 = p->total_height;
73
+    y1--;
74
+  }
75
+  p->page_y1 = y1;
76
+  
77
+  return 1;
78
+}
79
+
80
+
81
+

+ 191
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_pb.c View File

@@ -0,0 +1,191 @@
1
+/*
2
+
3
+  u8g_pb.c
4
+  
5
+  common procedures for the page buffer
6
+
7
+  Universal 8bit Graphics Library
8
+  
9
+  Copyright (c) 2011, olikraus@gmail.com
10
+  All rights reserved.
11
+
12
+  Redistribution and use in source and binary forms, with or without modification, 
13
+  are permitted provided that the following conditions are met:
14
+
15
+  * Redistributions of source code must retain the above copyright notice, this list 
16
+    of conditions and the following disclaimer.
17
+    
18
+  * Redistributions in binary form must reproduce the above copyright notice, this 
19
+    list of conditions and the following disclaimer in the documentation and/or other 
20
+    materials provided with the distribution.
21
+
22
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
23
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
24
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
25
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
26
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
27
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
28
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
29
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
30
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
31
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
32
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
33
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
34
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
35
+  
36
+  
37
+*/
38
+
39
+#include "u8g.h"
40
+
41
+void u8g_pb_Clear(u8g_pb_t *b)
42
+{
43
+  uint8_t *ptr = (uint8_t *)b->buf;
44
+  uint8_t *end_ptr = ptr;
45
+  end_ptr += b->width;
46
+  do
47
+  {
48
+    *ptr++ = 0;
49
+  } while( ptr != end_ptr );
50
+}
51
+
52
+/* the following procedure does not work. why? Can be checked with descpic */
53
+/*
54
+void u8g_pb_Clear(u8g_pb_t *b)
55
+{
56
+  uint8_t *ptr = (uint8_t *)b->buf;
57
+  uint8_t cnt = b->width;
58
+  do
59
+  {
60
+    *ptr++ = 0;
61
+    cnt--;
62
+  } while( cnt != 0 );
63
+}
64
+*/
65
+
66
+/*
67
+  intersection assumptions:
68
+    a1 <= a2 is always true    
69
+*/
70
+  /*
71
+    minimized version
72
+    ---1----0 1             b1 <= a2 && b1 > b2
73
+    -----1--0 1             b2 >= a1 && b1 > b2
74
+    ---1-1--- 1             b1 <= a2 && b2 >= a1
75
+  */
76
+/*
77
+uint8_t u8g_pb8v1_IsYIntersection___Old(u8g_pb_t *b, u8g_uint_t v0, u8g_uint_t v1)
78
+{
79
+  uint8_t c0, c1, c;
80
+  c0 = v0 <= b->p.page_y1;
81
+  c1 = v1 >= b->p.page_y0;
82
+  c = v0 > v1;
83
+  if ( c0 && c1 ) return 1;
84
+  if ( c0 && c ) return 1;
85
+  if ( c1 && c ) return 1;
86
+  return 0;
87
+}
88
+*/
89
+
90
+uint8_t u8g_pb_IsYIntersection(u8g_pb_t *pb, u8g_uint_t v0, u8g_uint_t v1)
91
+{
92
+  uint8_t c1, c2, c3, tmp;
93
+  c1 = v0 <= pb->p.page_y1;
94
+  c2 = v1 >= pb->p.page_y0;
95
+  c3 = v0 > v1;
96
+  /*
97
+  if ( c1 && c2 )
98
+    return 1;
99
+  if ( c1 && c3 )
100
+    return 1;
101
+  if ( c2 && c3 )
102
+    return 1;
103
+  return 0;
104
+  */
105
+  
106
+  tmp = c1;
107
+  c1 &= c2;
108
+  c2 &= c3;
109
+  c3 &= tmp;
110
+  c1 |= c2;
111
+  c1 |= c3;
112
+  return c1 & 1;
113
+}
114
+
115
+
116
+uint8_t u8g_pb_IsXIntersection(u8g_pb_t *b, u8g_uint_t v0, u8g_uint_t v1)
117
+{
118
+  uint8_t /*c0, c1, */ c2, c3;
119
+  /*
120
+    conditions: b->p.page_y0 < b->p.page_y1
121
+    there are no restriction on v0 and v1. If v0 > v1, then warp around unsigned is assumed
122
+  */
123
+  /*
124
+  c0 = v0 < 0;
125
+  c1 = v1 < 0;
126
+  */
127
+  c2 = v0 > b->width;
128
+  c3 = v1 > b->width;
129
+  /*if ( c0 && c1 ) return 0;*/
130
+  if ( c2 && c3 ) return 0;
131
+  /*if ( c1 && c2 ) return 0;*/
132
+  return 1;
133
+}
134
+
135
+uint8_t u8g_pb_IsIntersection(u8g_pb_t *pb, u8g_dev_arg_bbx_t *bbx)
136
+{
137
+  u8g_uint_t tmp;
138
+
139
+  tmp = bbx->y;
140
+  tmp += bbx->h;
141
+  tmp--;
142
+  
143
+  if ( u8g_pb_IsYIntersection(pb, bbx->y, tmp) == 0 )
144
+    return 0;
145
+  
146
+  /* maybe this one can be skiped... probability is very high to have an intersection, so it would be ok to always return 1 */
147
+  tmp = bbx->x;
148
+  tmp += bbx->w;
149
+  tmp--;
150
+    
151
+  return u8g_pb_IsXIntersection(pb, bbx->x, tmp);
152
+}
153
+
154
+void u8g_pb_GetPageBox(u8g_pb_t *pb, u8g_box_t *box)
155
+{
156
+  box->x0 = 0;
157
+  box->y0 = pb->p.page_y0;
158
+  box->x1 = pb->width;
159
+  box->x1--;
160
+  box->y1 = pb->p.page_y1;
161
+}
162
+
163
+
164
+uint8_t u8g_pb_Is8PixelVisible(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
165
+{
166
+  u8g_uint_t v0, v1;
167
+  v0 = arg_pixel->y;
168
+  v1 = v0;
169
+  switch( arg_pixel->dir )
170
+  {
171
+    case 0:
172
+      break;
173
+    case 1:  
174
+      v1 += 8;          /* this is independent from the page height */
175
+      break;
176
+    case 2:  
177
+      break;
178
+    case 3: 
179
+      v0 -= 8;
180
+      break;
181
+  }
182
+  return u8g_pb_IsYIntersection(b, v0, v1);
183
+}
184
+
185
+
186
+
187
+uint8_t u8g_pb_WriteBuffer(u8g_pb_t *b, u8g_t *u8g, u8g_dev_t *dev)
188
+{
189
+  return u8g_WriteSequence(u8g, dev, b->width, b->buf);  
190
+}
191
+

+ 200
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_pb14v1.c View File

@@ -0,0 +1,200 @@
1
+/*
2
+
3
+  u8g_pb14v1.c
4
+  
5
+  14bit height monochrom (1 bit) page buffer, 
6
+  byte has vertical orientation, 7 bits per byte
7
+
8
+  Universal 8bit Graphics Library
9
+  
10
+  Copyright (c) 2011, olikraus@gmail.com
11
+  All rights reserved.
12
+
13
+  Redistribution and use in source and binary forms, with or without modification, 
14
+  are permitted provided that the following conditions are met:
15
+
16
+  * Redistributions of source code must retain the above copyright notice, this list 
17
+    of conditions and the following disclaimer.
18
+    
19
+  * Redistributions in binary form must reproduce the above copyright notice, this 
20
+    list of conditions and the following disclaimer in the documentation and/or other 
21
+    materials provided with the distribution.
22
+
23
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
24
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
25
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
26
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
27
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
28
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
29
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
30
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
31
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
32
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
33
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
34
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
35
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
36
+  
37
+
38
+*/
39
+
40
+#include "u8g.h"
41
+#include <string.h>
42
+
43
+
44
+void u8g_pb14v1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE;
45
+void u8g_pb14v1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE;
46
+void u8g_pb14v1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel) U8G_NOINLINE ;
47
+void u8g_pb14v1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel) U8G_NOINLINE;
48
+
49
+
50
+void u8g_pb14v1_Clear(u8g_pb_t *b)
51
+{
52
+  uint8_t *ptr = (uint8_t *)b->buf;
53
+  uint8_t *end_ptr = ptr;
54
+  end_ptr += b->width*2;
55
+  do
56
+  {
57
+    *ptr++ = 0;
58
+  } while( ptr != end_ptr );
59
+}
60
+
61
+/* Obsolete, usually set by the init of the structure */
62
+void u8g_pb14v1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
63
+{
64
+  b->buf = buf;
65
+  b->width = width;
66
+  u8g_pb14v1_Clear(b);
67
+}
68
+
69
+void u8g_pb14v1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
70
+{
71
+  register uint8_t mask;
72
+  uint8_t *ptr = b->buf;
73
+  
74
+  y -= b->p.page_y0;
75
+  if ( y >= 7 )
76
+  {
77
+    ptr += b->width;
78
+    y -= 7;
79
+  }
80
+  mask = 1;
81
+  mask <<= y;
82
+  ptr += x;
83
+  if ( color_index )
84
+  {
85
+    *ptr |= mask;
86
+  }
87
+  else
88
+  {
89
+    mask ^=0xff;
90
+    *ptr &= mask;
91
+  }
92
+}
93
+
94
+
95
+void u8g_pb14v1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
96
+{
97
+  if ( arg_pixel->y < b->p.page_y0 )
98
+    return;
99
+  if ( arg_pixel->y > b->p.page_y1 )
100
+    return;
101
+  if ( arg_pixel->x >= b->width )
102
+    return;
103
+  u8g_pb14v1_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
104
+}
105
+
106
+void u8g_pb14v1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
107
+{
108
+  register uint8_t pixel = arg_pixel->pixel;
109
+  do
110
+  {
111
+    if ( pixel & 128 )
112
+    {
113
+      u8g_pb14v1_SetPixel(b, arg_pixel);
114
+    }
115
+    switch( arg_pixel->dir )
116
+    {
117
+      case 0: arg_pixel->x++; break;
118
+      case 1: arg_pixel->y++; break;
119
+      case 2: arg_pixel->x--; break;
120
+      case 3: arg_pixel->y--; break;
121
+    }
122
+    pixel <<= 1;
123
+  } while( pixel != 0  );
124
+}
125
+
126
+
127
+void u8g_pb14v1_Set8PixelOpt2(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
128
+{
129
+  register uint8_t pixel = arg_pixel->pixel;
130
+  u8g_uint_t dx = 0;
131
+  u8g_uint_t dy = 0;
132
+  
133
+  switch( arg_pixel->dir )
134
+  {
135
+    case 0: dx++; break;
136
+    case 1: dy++; break;
137
+    case 2: dx--; break;
138
+    case 3: dy--; break;
139
+  }
140
+  
141
+  do
142
+  {
143
+    if ( pixel & 128 )
144
+      u8g_pb14v1_SetPixel(b, arg_pixel);
145
+    arg_pixel->x += dx;
146
+    arg_pixel->y += dy;
147
+    pixel <<= 1;
148
+  } while( pixel != 0  );
149
+  
150
+}
151
+
152
+uint8_t u8g_dev_pb14v1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
153
+{
154
+  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
155
+  switch(msg)
156
+  {
157
+    case U8G_DEV_MSG_SET_8PIXEL:
158
+      if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
159
+        u8g_pb14v1_Set8PixelOpt2(pb, (u8g_dev_arg_pixel_t *)arg);
160
+      break;
161
+    case U8G_DEV_MSG_SET_PIXEL:
162
+        u8g_pb14v1_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
163
+      break;
164
+    case U8G_DEV_MSG_INIT:
165
+      break;
166
+    case U8G_DEV_MSG_STOP:
167
+      break;
168
+    case U8G_DEV_MSG_PAGE_FIRST:
169
+      u8g_pb14v1_Clear(pb);
170
+      u8g_page_First(&(pb->p));
171
+      break;
172
+    case U8G_DEV_MSG_PAGE_NEXT:
173
+      if ( u8g_page_Next(&(pb->p)) == 0 )
174
+        return 0;
175
+      u8g_pb14v1_Clear(pb);
176
+      break;
177
+#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
178
+    case U8G_DEV_MSG_IS_BBX_INTERSECTION:
179
+      return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
180
+#endif
181
+    case U8G_DEV_MSG_GET_PAGE_BOX:
182
+      u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
183
+      break;
184
+    case U8G_DEV_MSG_GET_WIDTH:
185
+      *((u8g_uint_t *)arg) = pb->width;
186
+      break;
187
+    case U8G_DEV_MSG_GET_HEIGHT:
188
+      *((u8g_uint_t *)arg) = pb->p.total_height;
189
+      break;
190
+    case U8G_DEV_MSG_SET_COLOR_INDEX:
191
+      break;
192
+    case U8G_DEV_MSG_SET_XY_CB:
193
+      break;
194
+    case U8G_DEV_MSG_GET_MODE:
195
+      return U8G_MODE_BW;
196
+  }
197
+  return 1;
198
+}
199
+ 
200
+  

+ 213
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_pb16h1.c View File

@@ -0,0 +1,213 @@
1
+/*
2
+
3
+  u8g_pb16h1.c
4
+  
5
+  2x 8bit height monochrom (1 bit) page buffer
6
+  byte has horizontal orientation
7
+
8
+  Universal 8bit Graphics Library
9
+  
10
+  Copyright (c) 2012, olikraus@gmail.com
11
+  All rights reserved.
12
+
13
+  Redistribution and use in source and binary forms, with or without modification, 
14
+  are permitted provided that the following conditions are met:
15
+
16
+  * Redistributions of source code must retain the above copyright notice, this list 
17
+    of conditions and the following disclaimer.
18
+    
19
+  * Redistributions in binary form must reproduce the above copyright notice, this 
20
+    list of conditions and the following disclaimer in the documentation and/or other 
21
+    materials provided with the distribution.
22
+
23
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
24
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
25
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
26
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
27
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
28
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
29
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
30
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
31
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
32
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
33
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
34
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
35
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
36
+
37
+
38
+  total buffer size is limited to 2*256 bytes because of the calculation inside the set pixel procedure
39
+
40
+
41
+*/
42
+
43
+#include "u8g.h"
44
+#include <string.h>
45
+
46
+
47
+void u8g_pb16h1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE;
48
+void u8g_pb16h1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE;
49
+void u8g_pb16h1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel) U8G_NOINLINE ;
50
+void u8g_pb16h1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel) U8G_NOINLINE;
51
+uint8_t u8g_dev_pb8h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg);
52
+
53
+void u8g_pb16h1_Clear(u8g_pb_t *b)
54
+{
55
+  uint8_t *ptr = (uint8_t *)b->buf;
56
+  uint8_t *end_ptr = ptr;
57
+  end_ptr += b->width*2;
58
+  do
59
+  {
60
+    *ptr++ = 0;
61
+  } while( ptr != end_ptr );
62
+}
63
+
64
+
65
+
66
+void u8g_pb16h1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
67
+{
68
+  b->buf = buf;
69
+  b->width = width;
70
+  u8g_pb16h1_Clear(b);
71
+}
72
+
73
+
74
+/* limitation: total buffer must not exceed 2*256 bytes */
75
+void u8g_pb16h1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
76
+{
77
+  register uint8_t mask;
78
+  u8g_uint_t tmp;
79
+  uint8_t *ptr = b->buf;
80
+  
81
+  y -= b->p.page_y0;
82
+  if ( y >= 8 )
83
+  {
84
+    ptr += b->width;
85
+    y &= 0x07;
86
+  }
87
+  tmp = b->width;
88
+  tmp >>= 3;
89
+  tmp *= (uint8_t)y;
90
+  ptr += tmp;
91
+  
92
+  mask = 0x080;
93
+  mask >>= x & 7;
94
+  x >>= 3;
95
+  ptr += x;
96
+  if ( color_index )
97
+  {
98
+    *ptr |= mask;
99
+  }
100
+  else
101
+  {
102
+    mask ^=0xff;
103
+    *ptr &= mask;
104
+  }
105
+  
106
+}
107
+
108
+
109
+void u8g_pb16h1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
110
+{
111
+  if ( arg_pixel->y < b->p.page_y0 )
112
+    return;
113
+  if ( arg_pixel->y > b->p.page_y1 )
114
+    return;
115
+  if ( arg_pixel->x >= b->width )
116
+    return;
117
+  u8g_pb16h1_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
118
+}
119
+
120
+void u8g_pb16h1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
121
+{
122
+  register uint8_t pixel = arg_pixel->pixel;
123
+  do
124
+  {
125
+    if ( pixel & 128 )
126
+    {
127
+      u8g_pb16h1_SetPixel(b, arg_pixel);
128
+    }
129
+    switch( arg_pixel->dir )
130
+    {
131
+      case 0: arg_pixel->x++; break;
132
+      case 1: arg_pixel->y++; break;
133
+      case 2: arg_pixel->x--; break;
134
+      case 3: arg_pixel->y--; break;
135
+    }
136
+    pixel <<= 1;
137
+  } while( pixel != 0  );
138
+}
139
+
140
+void u8g_pb16h1_Set8PixelOpt2(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
141
+{
142
+  register uint8_t pixel = arg_pixel->pixel;
143
+  u8g_uint_t dx = 0;
144
+  u8g_uint_t dy = 0;
145
+  
146
+  switch( arg_pixel->dir )
147
+  {
148
+    case 0: dx++; break;
149
+    case 1: dy++; break;
150
+    case 2: dx--; break;
151
+    case 3: dy--; break;
152
+  }
153
+  
154
+  do
155
+  {
156
+    if ( pixel & 128 )
157
+      u8g_pb16h1_SetPixel(b, arg_pixel);
158
+    arg_pixel->x += dx;
159
+    arg_pixel->y += dy;
160
+    pixel <<= 1;
161
+  } while( pixel != 0  );  
162
+}
163
+
164
+
165
+uint8_t u8g_dev_pb16h1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
166
+{
167
+  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
168
+  switch(msg)
169
+  {
170
+    case U8G_DEV_MSG_SET_8PIXEL:
171
+      if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
172
+        u8g_pb16h1_Set8PixelOpt2(pb, (u8g_dev_arg_pixel_t *)arg);
173
+      break;
174
+    case U8G_DEV_MSG_SET_PIXEL:
175
+      u8g_pb16h1_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
176
+      break;
177
+    case U8G_DEV_MSG_INIT:
178
+      break;
179
+    case U8G_DEV_MSG_STOP:
180
+      break;
181
+    case U8G_DEV_MSG_PAGE_FIRST:
182
+      u8g_pb16h1_Clear(pb);
183
+      u8g_page_First(&(pb->p));
184
+      break;
185
+    case U8G_DEV_MSG_PAGE_NEXT:
186
+      if ( u8g_page_Next(&(pb->p)) == 0 )
187
+        return 0;
188
+      u8g_pb16h1_Clear(pb);
189
+      break;
190
+#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
191
+    case U8G_DEV_MSG_IS_BBX_INTERSECTION:
192
+      return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
193
+#endif
194
+    case U8G_DEV_MSG_GET_PAGE_BOX:
195
+      u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
196
+      break;
197
+    case U8G_DEV_MSG_GET_WIDTH:
198
+      *((u8g_uint_t *)arg) = pb->width;
199
+      break;
200
+    case U8G_DEV_MSG_GET_HEIGHT:
201
+      *((u8g_uint_t *)arg) = pb->p.total_height;
202
+      break;
203
+    case U8G_DEV_MSG_SET_COLOR_INDEX:
204
+      break;
205
+    case U8G_DEV_MSG_SET_XY_CB:
206
+      break;
207
+    case U8G_DEV_MSG_GET_MODE:
208
+      return U8G_MODE_BW;
209
+  }
210
+  return 1;
211
+}
212
+ 
213
+  

+ 182
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_pb16h2.c View File

@@ -0,0 +1,182 @@
1
+/*
2
+
3
+  u8g_pb16h2.c
4
+  
5
+  2 bit per pixel page buffer
6
+  byte has horizontal orientation
7
+
8
+  Universal 8bit Graphics Library
9
+  
10
+  Copyright (c) 2011, olikraus@gmail.com
11
+  All rights reserved.
12
+
13
+  Redistribution and use in source and binary forms, with or without modification, 
14
+  are permitted provided that the following conditions are met:
15
+
16
+  * Redistributions of source code must retain the above copyright notice, this list 
17
+    of conditions and the following disclaimer.
18
+    
19
+  * Redistributions in binary form must reproduce the above copyright notice, this 
20
+    list of conditions and the following disclaimer in the documentation and/or other 
21
+    materials provided with the distribution.
22
+
23
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
24
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
25
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
26
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
27
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
28
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
29
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
30
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
31
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
32
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
33
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
34
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
35
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
36
+  
37
+
38
+*/
39
+
40
+#include "u8g.h"
41
+#include <string.h>
42
+
43
+void u8g_pb16h2_Clear(u8g_pb_t *b)
44
+{
45
+  uint8_t *ptr = (uint8_t *)b->buf;
46
+  uint8_t *end_ptr = ptr;
47
+  
48
+  /* two bits per pixel, 16 bits height --> 8 pixel --> 4 pixel per byte */
49
+  end_ptr += b->width;
50
+  end_ptr += b->width;
51
+  
52
+  do
53
+  {
54
+    *ptr++ = 0;
55
+  } while( ptr != end_ptr );
56
+}
57
+
58
+void u8g_pb16h2_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
59
+{
60
+  b->buf = buf;
61
+  b->width = width;
62
+  u8g_pb16h2_Clear(b);
63
+}
64
+
65
+static void u8g_pb16h2_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE;
66
+static void u8g_pb16h2_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
67
+{
68
+  register uint8_t mask;
69
+  register uint16_t tmp;
70
+  
71
+  uint8_t *ptr = b->buf;
72
+  
73
+  y -= b->p.page_y0;
74
+  
75
+  tmp = b->width;
76
+  tmp >>= 2;
77
+  tmp *= (uint8_t)y;
78
+  ptr += tmp;
79
+  
80
+  tmp = x;
81
+  tmp >>= 2;
82
+  ptr += tmp;
83
+  
84
+  tmp = x;
85
+  tmp &= 3;
86
+  tmp <<= 1;
87
+  mask = 3;
88
+  mask <<= tmp;
89
+  mask = ~mask;
90
+  color_index &= 3;
91
+  color_index <<= tmp;
92
+    
93
+  *ptr &= mask;
94
+  *ptr |= color_index;
95
+}
96
+
97
+
98
+void u8g_pb16h2_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
99
+{
100
+  if ( arg_pixel->y < b->p.page_y0 )
101
+    return;
102
+  if ( arg_pixel->y > b->p.page_y1 )
103
+    return;
104
+  if ( arg_pixel->x >= b->width )
105
+    return;
106
+  u8g_pb16h2_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
107
+}
108
+
109
+
110
+void u8g_pb16h2_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
111
+{
112
+  register uint8_t pixel = arg_pixel->pixel;
113
+  do
114
+  {
115
+    if ( pixel & 128 )
116
+    {
117
+      u8g_pb16h2_SetPixel(b, arg_pixel);
118
+    }
119
+    switch( arg_pixel->dir )
120
+    {
121
+      case 0: arg_pixel->x++; break;
122
+      case 1: arg_pixel->y++; break;
123
+      case 2: arg_pixel->x--; break;
124
+      case 3: arg_pixel->y--; break;
125
+    }
126
+    pixel <<= 1;
127
+  } while( pixel != 0  );
128
+}
129
+
130
+
131
+
132
+uint8_t u8g_dev_pb16h2_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
133
+{
134
+  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
135
+  switch(msg)
136
+  {
137
+    case U8G_DEV_MSG_SET_8PIXEL:
138
+      if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
139
+      {
140
+        u8g_pb16h2_Set8PixelStd(pb, (u8g_dev_arg_pixel_t *)arg);
141
+      }
142
+      break;
143
+    case U8G_DEV_MSG_SET_PIXEL:
144
+      u8g_pb16h2_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
145
+      break;
146
+    case U8G_DEV_MSG_INIT:
147
+      break;
148
+    case U8G_DEV_MSG_STOP:
149
+      break;
150
+    case U8G_DEV_MSG_PAGE_FIRST:
151
+      u8g_page_First(&(pb->p));
152
+      u8g_pb16h2_Clear(pb);
153
+      break;
154
+    case U8G_DEV_MSG_PAGE_NEXT:
155
+      if ( u8g_page_Next(&(pb->p)) == 0 )
156
+        return 0;
157
+      u8g_pb16h2_Clear(pb);
158
+      break;
159
+#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
160
+    case U8G_DEV_MSG_IS_BBX_INTERSECTION:
161
+      return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
162
+#endif
163
+    case U8G_DEV_MSG_GET_PAGE_BOX:
164
+      u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
165
+      break;
166
+    case U8G_DEV_MSG_GET_WIDTH:
167
+      *((u8g_uint_t *)arg) = pb->width;
168
+      break;
169
+    case U8G_DEV_MSG_GET_HEIGHT:
170
+      *((u8g_uint_t *)arg) = pb->p.total_height;
171
+      break;
172
+    case U8G_DEV_MSG_SET_COLOR_INDEX:
173
+      break;
174
+    case U8G_DEV_MSG_SET_XY_CB:
175
+      break;
176
+    case U8G_DEV_MSG_GET_MODE:
177
+      return U8G_MODE_GRAY2BIT;
178
+  }
179
+  return 1;
180
+}
181
+ 
182
+  

+ 200
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_pb16v1.c View File

@@ -0,0 +1,200 @@
1
+/*
2
+
3
+  u8g_pb16v1.c
4
+  
5
+  16bit height monochrom (1 bit) page buffer
6
+  byte has vertical orientation
7
+
8
+  Universal 8bit Graphics Library
9
+  
10
+  Copyright (c) 2011, olikraus@gmail.com
11
+  All rights reserved.
12
+
13
+  Redistribution and use in source and binary forms, with or without modification, 
14
+  are permitted provided that the following conditions are met:
15
+
16
+  * Redistributions of source code must retain the above copyright notice, this list 
17
+    of conditions and the following disclaimer.
18
+    
19
+  * Redistributions in binary form must reproduce the above copyright notice, this 
20
+    list of conditions and the following disclaimer in the documentation and/or other 
21
+    materials provided with the distribution.
22
+
23
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
24
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
25
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
26
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
27
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
28
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
29
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
30
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
31
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
32
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
33
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
34
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
35
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
36
+  
37
+
38
+*/
39
+
40
+#include "u8g.h"
41
+#include <string.h>
42
+
43
+
44
+void u8g_pb16v1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width) U8G_NOINLINE;
45
+void u8g_pb16v1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index) U8G_NOINLINE;
46
+void u8g_pb16v1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel) U8G_NOINLINE ;
47
+void u8g_pb16v1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel) U8G_NOINLINE;
48
+
49
+
50
+void u8g_pb16v1_Clear(u8g_pb_t *b)
51
+{
52
+  uint8_t *ptr = (uint8_t *)b->buf;
53
+  uint8_t *end_ptr = ptr;
54
+  end_ptr += b->width*2;
55
+  do
56
+  {
57
+    *ptr++ = 0;
58
+  } while( ptr != end_ptr );
59
+}
60
+
61
+/* Obsolete, usually set by the init of the structure */
62
+void u8g_pb16v1_Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
63
+{
64
+  b->buf = buf;
65
+  b->width = width;
66
+  u8g_pb16v1_Clear(b);
67
+}
68
+
69
+void u8g_pb16v1_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
70
+{
71
+  register uint8_t mask;
72
+  uint8_t *ptr = b->buf;
73
+  
74
+  y -= b->p.page_y0;
75
+  if ( y >= 8 )
76
+  {
77
+    ptr += b->width;
78
+    y &= 0x07;
79
+  }
80
+  mask = 1;
81
+  mask <<= y;
82
+  ptr += x;
83
+  if ( color_index )
84
+  {
85
+    *ptr |= mask;
86
+  }
87
+  else
88
+  {
89
+    mask ^=0xff;
90
+    *ptr &= mask;
91
+  }
92
+}
93
+
94
+
95
+void u8g_pb16v1_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
96
+{
97
+  if ( arg_pixel->y < b->p.page_y0 )
98
+    return;
99
+  if ( arg_pixel->y > b->p.page_y1 )
100
+    return;
101
+  if ( arg_pixel->x >= b->width )
102
+    return;
103
+  u8g_pb16v1_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
104
+}
105
+
106
+void u8g_pb16v1_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
107
+{
108
+  register uint8_t pixel = arg_pixel->pixel;
109
+  do
110
+  {
111
+    if ( pixel & 128 )
112
+    {
113
+      u8g_pb16v1_SetPixel(b, arg_pixel);
114
+    }
115
+    switch( arg_pixel->dir )
116
+    {
117
+      case 0: arg_pixel->x++; break;
118
+      case 1: arg_pixel->y++; break;
119
+      case 2: arg_pixel->x--; break;
120
+      case 3: arg_pixel->y--; break;
121
+    }
122
+    pixel <<= 1;
123
+  } while( pixel != 0  );
124
+}
125
+
126
+
127
+void u8g_pb16v1_Set8PixelOpt2(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
128
+{
129
+  register uint8_t pixel = arg_pixel->pixel;
130
+  u8g_uint_t dx = 0;
131
+  u8g_uint_t dy = 0;
132
+  
133
+  switch( arg_pixel->dir )
134
+  {
135
+    case 0: dx++; break;
136
+    case 1: dy++; break;
137
+    case 2: dx--; break;
138
+    case 3: dy--; break;
139
+  }
140
+  
141
+  do
142
+  {
143
+    if ( pixel & 128 )
144
+      u8g_pb16v1_SetPixel(b, arg_pixel);
145
+    arg_pixel->x += dx;
146
+    arg_pixel->y += dy;
147
+    pixel <<= 1;
148
+  } while( pixel != 0  );
149
+  
150
+}
151
+
152
+uint8_t u8g_dev_pb16v1_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
153
+{
154
+  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
155
+  switch(msg)
156
+  {
157
+    case U8G_DEV_MSG_SET_8PIXEL:
158
+      if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
159
+        u8g_pb16v1_Set8PixelOpt2(pb, (u8g_dev_arg_pixel_t *)arg);
160
+      break;
161
+    case U8G_DEV_MSG_SET_PIXEL:
162
+        u8g_pb16v1_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
163
+      break;
164
+    case U8G_DEV_MSG_INIT:
165
+      break;
166
+    case U8G_DEV_MSG_STOP:
167
+      break;
168
+    case U8G_DEV_MSG_PAGE_FIRST:
169
+      u8g_pb16v1_Clear(pb);
170
+      u8g_page_First(&(pb->p));
171
+      break;
172
+    case U8G_DEV_MSG_PAGE_NEXT:
173
+      if ( u8g_page_Next(&(pb->p)) == 0 )
174
+        return 0;
175
+      u8g_pb16v1_Clear(pb);
176
+      break;
177
+#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
178
+    case U8G_DEV_MSG_IS_BBX_INTERSECTION:
179
+      return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
180
+#endif
181
+    case U8G_DEV_MSG_GET_PAGE_BOX:
182
+      u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
183
+      break;
184
+    case U8G_DEV_MSG_GET_WIDTH:
185
+      *((u8g_uint_t *)arg) = pb->width;
186
+      break;
187
+    case U8G_DEV_MSG_GET_HEIGHT:
188
+      *((u8g_uint_t *)arg) = pb->p.total_height;
189
+      break;
190
+    case U8G_DEV_MSG_SET_COLOR_INDEX:
191
+      break;
192
+    case U8G_DEV_MSG_SET_XY_CB:
193
+      break;
194
+    case U8G_DEV_MSG_GET_MODE:
195
+      return U8G_MODE_BW;
196
+  }
197
+  return 1;
198
+}
199
+ 
200
+  

+ 172
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_pb16v2.c View File

@@ -0,0 +1,172 @@
1
+/*
2
+
3
+  u8g_pb16v2.c
4
+  
5
+  16 bit height 2 bit per pixel page buffer
6
+  byte has vertical orientation
7
+
8
+  Universal 8bit Graphics Library
9
+  
10
+  Copyright (c) 2012, olikraus@gmail.com
11
+  All rights reserved.
12
+
13
+  Redistribution and use in source and binary forms, with or without modification, 
14
+  are permitted provided that the following conditions are met:
15
+
16
+  * Redistributions of source code must retain the above copyright notice, this list 
17
+    of conditions and the following disclaimer.
18
+    
19
+  * Redistributions in binary form must reproduce the above copyright notice, this 
20
+    list of conditions and the following disclaimer in the documentation and/or other 
21
+    materials provided with the distribution.
22
+
23
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 
24
+  CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 
25
+  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
26
+  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
27
+  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
28
+  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
29
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 
30
+  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
31
+  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
32
+  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
33
+  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
34
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 
35
+  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  
36
+  
37
+
38
+*/
39
+
40
+#include "u8g.h"
41
+#include <string.h>
42
+
43
+
44
+void u8g_pb16v2_Clear(u8g_pb_t *b)
45
+{
46
+  uint8_t *ptr = (uint8_t *)b->buf;
47
+  uint8_t *end_ptr = ptr;
48
+  
49
+  /* two bits per pixel, 16 bits height --> 8 pixel --> 4 pixel per byte */
50
+  end_ptr += b->width;
51
+  end_ptr += b->width;
52
+  
53
+  do
54
+  {
55
+    *ptr++ = 0;
56
+  } while( ptr != end_ptr );
57
+}
58
+
59
+void u8g_pb16v2Init(u8g_pb_t *b, void *buf, u8g_uint_t width)
60
+{
61
+  b->buf = buf;
62
+  b->width = width;
63
+  u8g_pb16v2_Clear(b);
64
+}
65
+
66
+void u8g_pb16v2_set_pixel(u8g_pb_t *b, u8g_uint_t x, u8g_uint_t y, uint8_t color_index)
67
+{
68
+  register uint8_t mask;
69
+  uint8_t *ptr = b->buf;
70
+  y -= b->p.page_y0;
71
+  if ( y >= 4 )
72
+  {
73
+    ptr += b->width;
74
+  }
75
+  mask = 0x03;
76
+  y &= 0x03;
77
+  y <<= 1;
78
+  mask <<= y;
79
+  mask ^=0xff;
80
+  color_index &= 3;
81
+  color_index <<= y;
82
+  ptr += x;
83
+  *ptr &= mask;
84
+  *ptr |= color_index;
85
+}
86
+
87
+
88
+void u8g_pb16v2_SetPixel(u8g_pb_t *b, const u8g_dev_arg_pixel_t * const arg_pixel)
89
+{
90
+  if ( arg_pixel->y < b->p.page_y0 )
91
+    return;
92
+  if ( arg_pixel->y > b->p.page_y1 )
93
+    return;
94
+  if ( arg_pixel->x >= b->width )
95
+    return;
96
+  u8g_pb16v2_set_pixel(b, arg_pixel->x, arg_pixel->y, arg_pixel->color);
97
+}
98
+
99
+
100
+void u8g_pb16v2_Set8PixelStd(u8g_pb_t *b, u8g_dev_arg_pixel_t *arg_pixel)
101
+{
102
+  register uint8_t pixel = arg_pixel->pixel;
103
+  do
104
+  {
105
+    if ( pixel & 128 )
106
+    {
107
+      u8g_pb16v2_SetPixel(b, arg_pixel);
108
+    }
109
+    switch( arg_pixel->dir )
110
+    {
111
+      case 0: arg_pixel->x++; break;
112
+      case 1: arg_pixel->y++; break;
113
+      case 2: arg_pixel->x--; break;
114
+      case 3: arg_pixel->y--; break;
115
+    }
116
+    pixel <<= 1;
117
+  } while( pixel != 0  );
118
+}
119
+
120
+
121
+
122
+uint8_t u8g_dev_pb16v2_base_fn(u8g_t *u8g, u8g_dev_t *dev, uint8_t msg, void *arg)
123
+{
124
+  u8g_pb_t *pb = (u8g_pb_t *)(dev->dev_mem);
125
+  switch(msg)
126
+  {
127
+    case U8G_DEV_MSG_SET_8PIXEL:
128
+      if ( u8g_pb_Is8PixelVisible(pb, (u8g_dev_arg_pixel_t *)arg) )
129
+      {
130
+        u8g_pb16v2_Set8PixelStd(pb, (u8g_dev_arg_pixel_t *)arg);
131
+      }
132
+      break;
133
+    case U8G_DEV_MSG_SET_PIXEL:
134
+      u8g_pb16v2_SetPixel(pb, (u8g_dev_arg_pixel_t *)arg);
135
+      break;
136
+    case U8G_DEV_MSG_INIT:
137
+      break;
138
+    case U8G_DEV_MSG_STOP:
139
+      break;
140
+    case U8G_DEV_MSG_PAGE_FIRST:
141
+      u8g_pb16v2_Clear(pb);
142
+      u8g_page_First(&(pb->p));
143
+      break;
144
+    case U8G_DEV_MSG_PAGE_NEXT:
145
+      if ( u8g_page_Next(&(pb->p)) == 0 )
146
+        return 0;
147
+      u8g_pb16v2_Clear(pb);
148
+      break;
149
+#ifdef U8G_DEV_MSG_IS_BBX_INTERSECTION
150
+    case U8G_DEV_MSG_IS_BBX_INTERSECTION:
151
+      return u8g_pb_IsIntersection(pb, (u8g_dev_arg_bbx_t *)arg);
152
+#endif
153
+    case U8G_DEV_MSG_GET_PAGE_BOX:
154
+      u8g_pb_GetPageBox(pb, (u8g_box_t *)arg);
155
+      break;
156
+    case U8G_DEV_MSG_GET_WIDTH:
157
+      *((u8g_uint_t *)arg) = pb->width;
158
+      break;
159
+    case U8G_DEV_MSG_GET_HEIGHT:
160
+      *((u8g_uint_t *)arg) = pb->p.total_height;
161
+      break;
162
+    case U8G_DEV_MSG_SET_COLOR_INDEX:
163
+      break;
164
+    case U8G_DEV_MSG_SET_XY_CB:
165
+      break;
166
+    case U8G_DEV_MSG_GET_MODE:
167
+      return U8G_MODE_GRAY2BIT;
168
+  }
169
+  return 1;
170
+}
171
+ 
172
+  

+ 0
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_pb32h1.c View File


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save