ソースを参照

Merge remote-tracking branch 'upstream/Marlin_v1' into Marlin_v1

Robert F-C 12年前
コミット
c3cdaceab3
100個のファイルの変更22740行の追加264行の削除
  1. 83
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/boards.txt
  2. 470
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega1284p/Makefile
  3. 848
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega1284p/boot.h
  4. 724
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega1284p/optiboot.c
  5. 33
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega1284p/optiboot_1284P_20MHz_57k6_baud.hex
  6. 81
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega1284p/pin_defs.h
  7. 39
    0
      ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega1284p/stk500.h
  8. 0
    135
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/Copy of wiring.h
  9. 129
    13
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/HardwareSerial.cpp
  10. 42
    11
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/WInterrupts.c
  11. 520
    93
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/pins_arduino.c
  12. 32
    8
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/pins_arduino.h
  13. 4
    2
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/wiring.h
  14. 4
    2
      ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/wiring_private.h
  15. 114
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/ChangeLog
  16. 21
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/INSTALL.TXT
  17. 80
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/U8glib.cpp
  18. 826
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/U8glib.h
  19. 130
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/Bitmap/Bitmap.pde
  20. 180
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/Chess/Chess.pde
  21. 230
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/Console/Console.pde
  22. 139
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/F/F.pde
  23. 223
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/GraphicsTest/GraphicsTest.pde
  24. 136
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/HelloWorld/HelloWorld.pde
  25. 234
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/Menu/Menu.pde
  26. 124
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/PrintTest/PrintTest.pde
  27. 152
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/Rotation/Rotation.pde
  28. 141
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/Scale/Scale.pde
  29. 154
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/TextRotX/TextRotX.pde
  30. 179
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/U8gLogo/U8gLogo.pde
  31. 136
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/examples/XBM/XBM.pde
  32. 80
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/license.txt
  33. 2392
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/chessengine.c
  34. 1607
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g.h
  35. 177
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_bitmap.c
  36. 382
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_circle.c
  37. 156
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_clip.c
  38. 173
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_api.c
  39. 94
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_api_16gr.c
  40. 75
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_common.c
  41. 245
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_fast_parallel.c
  42. 191
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_hw_spi.c
  43. 221
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_no_en_parallel.c
  44. 187
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_parallel.c
  45. 168
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_port_d_wr.c
  46. 201
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_ssd_i2c.c
  47. 220
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_st7920_hw_spi.c
  48. 295
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_st7920_spi.c
  49. 144
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_std_sw_spi.c
  50. 239
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_sw_spi.c
  51. 385
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_arduino_t6963.c
  52. 174
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_atmega_hw_spi.c
  53. 183
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_atmega_parallel.c
  54. 205
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_atmega_st7920_hw_spi.c
  55. 170
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_atmega_st7920_spi.c
  56. 141
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_atmega_sw_spi.c
  57. 249
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_i2c.c
  58. 218
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_io.c
  59. 63
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_com_null.c
  60. 99
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_cursor.c
  61. 215
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_delay.c
  62. 92
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_flipdisc_2x7.c
  63. 130
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_gprof.c
  64. 326
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ili9325d_320x240.c
  65. 110
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ks0108_128x64.c
  66. 147
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_lc7981_160x80.c
  67. 145
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_lc7981_240x128.c
  68. 145
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_lc7981_240x64.c
  69. 145
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_lc7981_320x64.c
  70. 67
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_null.c
  71. 110
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_pcd8544_84x48.c
  72. 123
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_pcf8812_96x65.c
  73. 107
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_sbn1661_122x32.c
  74. 247
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1306_128x32.c
  75. 237
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1306_128x64.c
  76. 144
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1309_128x64.c
  77. 334
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1322_nhd31oled_bw.c
  78. 333
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1322_nhd31oled_gr.c
  79. 263
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1325_nhd27oled_bw.c
  80. 232
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1325_nhd27oled_bw_new.c
  81. 255
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1325_nhd27oled_gr.c
  82. 227
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1325_nhd27oled_gr_new.c
  83. 299
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_ssd1327_96x96_gr.c
  84. 153
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7565_64128n.c
  85. 140
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7565_dogm128.c
  86. 157
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7565_dogm132.c
  87. 157
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7565_lm6059.c
  88. 188
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7565_lm6063.c
  89. 143
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7565_nhd_c12832.c
  90. 145
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7565_nhd_c12864.c
  91. 420
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7687_c144mvgd.c
  92. 171
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7920_128x64.c
  93. 151
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7920_192x32.c
  94. 154
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_st7920_202x32.c
  95. 191
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_t6963_128x64.c
  96. 195
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_t6963_240x128.c
  97. 195
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_t6963_240x64.c
  98. 115
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_tls8204_84x48.c
  99. 290
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_uc1610_dogxl160.c
  100. 0
    0
      ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_uc1701_dogs102.c

+ 83
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/boards.txt ファイルの表示

@@ -14,3 +14,86 @@ sanguino.bootloader.lock_bits=0x0F
14 14
 sanguino.build.mcu=atmega644p
15 15
 sanguino.build.f_cpu=16000000L
16 16
 sanguino.build.core=arduino
17
+
18
+##############################################################
19
+
20
+atmega644.name=Sanguino W/ ATmega644P
21
+
22
+atmega644.upload.protocol=stk500
23
+atmega644.upload.maximum_size=63488
24
+atmega644.upload.speed=57600
25
+
26
+atmega644.bootloader.low_fuses=0xFF
27
+atmega644.bootloader.high_fuses=0x9A
28
+atmega644.bootloader.extended_fuses=0xFF
29
+atmega644.bootloader.path=atmega
30
+atmega644.bootloader.file=ATmegaBOOT_168_atmega644p.hex
31
+#atmega644.bootloader.file=ATmegaBOOT_644P.hex
32
+atmega644.bootloader.unlock_bits=0x3F
33
+atmega644.bootloader.lock_bits=0x0F
34
+
35
+atmega644.build.mcu=atmega644p
36
+atmega644.build.f_cpu=16000000L
37
+atmega644.build.core=arduino
38
+
39
+##############################################################
40
+
41
+atmega12848m.name=Sanguino W/ ATmega1284p 8mhz
42
+
43
+atmega12848m.upload.protocol=stk500
44
+atmega12848m.upload.maximum_size=131072
45
+atmega12848m.upload.speed=19200
46
+
47
+atmega12848m.bootloader.low_fuses=0xFD
48
+atmega12848m.bootloader.high_fuses=0x9A
49
+atmega12848m.bootloader.extended_fuses=0xFF
50
+atmega12848m.bootloader.path=atmega
51
+atmega12848m.bootloader.file=ATmegaBOOT_168_atmega1284p_8m.hex
52
+atmega12848m.bootloader.unlock_bits=0x3F
53
+atmega12848m.bootloader.lock_bits=0x0F
54
+
55
+atmega12848m.build.mcu=atmega1284p
56
+atmega12848m.build.f_cpu=8000000L
57
+atmega12848m.build.core=arduino
58
+
59
+##############################################################
60
+
61
+atmega1284.name=Sanguino W/ ATmega1284p 16mhz
62
+
63
+atmega1284.upload.protocol=stk500
64
+atmega1284.upload.maximum_size=131072
65
+atmega1284.upload.speed=57600
66
+
67
+atmega1284.bootloader.low_fuses=0xFF
68
+atmega1284.bootloader.high_fuses=0x9A
69
+atmega1284.bootloader.extended_fuses=0xFF
70
+atmega1284.bootloader.path=atmega
71
+atmega1284.bootloader.file=ATmegaBOOT_168_atmega1284p.hex
72
+atmega1284.bootloader.unlock_bits=0x3F
73
+atmega1284.bootloader.lock_bits=0x0F
74
+
75
+atmega1284.build.mcu=atmega1284p
76
+atmega1284.build.f_cpu=16000000L
77
+atmega1284.build.core=arduino
78
+
79
+
80
+##############################################################
81
+
82
+atmega1284s.name=Sanguino W/ ATmega1284p 20mhz
83
+
84
+atmega1284s.upload.protocol=stk500
85
+atmega1284s.upload.maximum_size=131072
86
+atmega1284s.upload.speed=57600
87
+
88
+atmega1284s.bootloader.low_fuses=0xFF
89
+atmega1284s.bootloader.high_fuses=0x9A
90
+atmega1284s.bootloader.extended_fuses=0xFF
91
+atmega1284s.bootloader.path=atmega
92
+atmega1284s.bootloader.file=ATmegaBOOT_168_atmega1284p.hex
93
+atmega1284s.bootloader.unlock_bits=0x3F
94
+atmega1284s.bootloader.lock_bits=0x0F
95
+
96
+atmega1284s.build.mcu=atmega1284p
97
+atmega1284s.build.f_cpu=20000000L
98
+atmega1284s.build.core=arduino
99
+#

+ 470
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega1284p/Makefile ファイルの表示

@@ -0,0 +1,470 @@
1
+# Makefile for ATmegaBOOT
2
+# E.Lins, 18.7.2005
3
+# $Id$
4
+#
5
+# Instructions
6
+#
7
+# To make bootloader .hex file:
8
+# make diecimila
9
+# make lilypad
10
+# make ng
11
+# etc...
12
+#
13
+# To burn bootloader .hex file:
14
+# make diecimila_isp
15
+# make lilypad_isp
16
+# make ng_isp
17
+# etc...
18
+
19
+# program name should not be changed...
20
+PROGRAM    = optiboot
21
+
22
+# The default behavior is to build using tools that are in the users
23
+# current path variables, but we can also build using an installed
24
+# Arduino user IDE setup, or the Arduino source tree.
25
+# Uncomment this next lines to build within the arduino environment,
26
+# using the arduino-included avrgcc toolset (mac and pc)
27
+# ENV ?= arduino
28
+# ENV ?= arduinodev
29
+# OS ?= macosx
30
+# OS ?= windows
31
+
32
+
33
+# enter the parameters for the avrdude isp tool
34
+ISPTOOL    = stk500v2
35
+ISPPORT    = usb
36
+ISPSPEED   = -b 115200
37
+
38
+MCU_TARGET = atmega168
39
+LDSECTIONS  = -Wl,--section-start=.text=0x3e00 -Wl,--section-start=.version=0x3ffe
40
+
41
+# Build environments
42
+# Start of some ugly makefile-isms to allow optiboot to be built
43
+# in several different environments.  See the README.TXT file for
44
+# details.
45
+
46
+# default
47
+fixpath = $(1)
48
+
49
+ifeq ($(ENV), arduino)
50
+# For Arduino, we assume that we're connected to the optiboot directory
51
+# included with the arduino distribution, which means that the full set
52
+# of avr-tools are "right up there" in standard places.
53
+TOOLROOT = ../../../tools
54
+GCCROOT = $(TOOLROOT)/avr/bin/
55
+AVRDUDE_CONF = -C$(TOOLROOT)/avr/etc/avrdude.conf
56
+
57
+ifeq ($(OS), windows)
58
+# On windows, SOME of the tool paths will need to have backslashes instead
59
+# of forward slashes (because they use windows cmd.exe for execution instead
60
+# of a unix/mingw shell?)  We also have to ensure that a consistent shell
61
+# is used even if a unix shell is installed (ie as part of WINAVR)
62
+fixpath = $(subst /,\,$1)
63
+SHELL = cmd.exe
64
+endif
65
+
66
+else ifeq ($(ENV), arduinodev)
67
+# Arduino IDE source code environment.  Use the unpacked compilers created
68
+# by the build (you'll need to do "ant build" first.)
69
+ifeq ($(OS), macosx)
70
+TOOLROOT = ../../../../build/macosx/work/Arduino.app/Contents/Resources/Java/hardware/tools
71
+endif
72
+ifeq ($(OS), windows)
73
+TOOLROOT = ../../../../build/windows/work/hardware/tools
74
+endif
75
+
76
+GCCROOT = $(TOOLROOT)/avr/bin/
77
+AVRDUDE_CONF = -C$(TOOLROOT)/avr/etc/avrdude.conf
78
+
79
+else
80
+GCCROOT =
81
+AVRDUDE_CONF =
82
+endif
83
+#
84
+# End of build environment code.
85
+
86
+
87
+# the efuse should really be 0xf8; since, however, only the lower
88
+# three bits of that byte are used on the atmega168, avrdude gets
89
+# confused if you specify 1's for the higher bits, see:
90
+# http://tinker.it/now/2007/02/24/the-tale-of-avrdude-atmega168-and-extended-bits-fuses/
91
+#
92
+# similarly, the lock bits should be 0xff instead of 0x3f (to
93
+# unlock the bootloader section) and 0xcf instead of 0x2f (to
94
+# lock it), but since the high two bits of the lock byte are
95
+# unused, avrdude would get confused.
96
+
97
+ISPFUSES    = $(GCCROOT)avrdude $(AVRDUDE_CONF) -c $(ISPTOOL) \
98
+              -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
99
+              -e -u -U lock:w:0x3f:m -U efuse:w:0x$(EFUSE):m \
100
+              -U hfuse:w:0x$(HFUSE):m -U lfuse:w:0x$(LFUSE):m
101
+ISPFLASH    = $(GCCROOT)avrdude $(AVRDUDE_CONF) -c $(ISPTOOL) \
102
+              -p $(MCU_TARGET) -P $(ISPPORT) $(ISPSPEED) \
103
+              -U flash:w:$(PROGRAM)_$(TARGET).hex -U lock:w:0x2f:m
104
+
105
+STK500 = "C:\Program Files\Atmel\AVR Tools\STK500\Stk500.exe"
106
+STK500-1 = $(STK500) -e -d$(MCU_TARGET) -pf -vf -if$(PROGRAM)_$(TARGET).hex \
107
+-lFF -LFF -f$(HFUSE)$(LFUSE) -EF8 -ms -q -cUSB -I200kHz -s -wt
108
+STK500-2 = $(STK500) -d$(MCU_TARGET) -ms -q -lCF -LCF -cUSB -I200kHz -s -wt
109
+
110
+OBJ        = $(PROGRAM).o
111
+OPTIMIZE = -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls
112
+
113
+DEFS       = 
114
+LIBS       =
115
+
116
+CC         = $(GCCROOT)avr-gcc
117
+
118
+# Override is only needed by avr-lib build system.
119
+
120
+override CFLAGS        = -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) -DF_CPU=$(AVR_FREQ) $(DEFS)
121
+override LDFLAGS       = $(LDSECTIONS) -Wl,--relax -Wl,--gc-sections -nostartfiles -nostdlib
122
+
123
+OBJCOPY        = $(GCCROOT)avr-objcopy
124
+OBJDUMP        = $(call fixpath,$(GCCROOT)avr-objdump)
125
+
126
+SIZE           = $(GCCROOT)avr-size
127
+
128
+# Test platforms
129
+# Virtual boot block test
130
+virboot328: TARGET = atmega328
131
+virboot328: MCU_TARGET = atmega328p
132
+virboot328: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DVIRTUAL_BOOT'
133
+virboot328: AVR_FREQ = 16000000L
134
+virboot328: LDSECTIONS  = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
135
+virboot328: $(PROGRAM)_atmega328.hex
136
+virboot328: $(PROGRAM)_atmega328.lst
137
+
138
+# 20MHz clocked platforms
139
+#
140
+# These are capable of 230400 baud, or 115200 baud on PC (Arduino Avrdude issue)
141
+#
142
+
143
+pro20: TARGET = pro_20mhz
144
+pro20: MCU_TARGET = atmega168
145
+pro20: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
146
+pro20: AVR_FREQ = 20000000L
147
+pro20: $(PROGRAM)_pro_20mhz.hex
148
+pro20: $(PROGRAM)_pro_20mhz.lst
149
+
150
+pro20_isp: pro20
151
+pro20_isp: TARGET = pro_20mhz
152
+# 2.7V brownout
153
+pro20_isp: HFUSE = DD
154
+# Full swing xtal (20MHz) 258CK/14CK+4.1ms
155
+pro20_isp: LFUSE = C6
156
+# 512 byte boot
157
+pro20_isp: EFUSE = 04
158
+pro20_isp: isp
159
+
160
+# 16MHz clocked platforms
161
+#
162
+# These are capable of 230400 baud, or 115200 baud on PC (Arduino Avrdude issue)
163
+#
164
+
165
+pro16: TARGET = pro_16MHz
166
+pro16: MCU_TARGET = atmega168
167
+pro16: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
168
+pro16: AVR_FREQ = 16000000L
169
+pro16: $(PROGRAM)_pro_16MHz.hex
170
+pro16: $(PROGRAM)_pro_16MHz.lst
171
+
172
+pro16_isp: pro16
173
+pro16_isp: TARGET = pro_16MHz
174
+# 2.7V brownout
175
+pro16_isp: HFUSE = DD
176
+# Full swing xtal (20MHz) 258CK/14CK+4.1ms
177
+pro16_isp: LFUSE = C6
178
+# 512 byte boot
179
+pro16_isp: EFUSE = 04
180
+pro16_isp: isp
181
+
182
+# Diecimila, Duemilanove with m168, and NG use identical bootloaders
183
+# Call it "atmega168" for generality and clarity, keep "diecimila" for
184
+# backward compatibility of makefile
185
+#
186
+atmega168: TARGET = atmega168
187
+atmega168: MCU_TARGET = atmega168
188
+atmega168: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
189
+atmega168: AVR_FREQ = 16000000L 
190
+atmega168: $(PROGRAM)_atmega168.hex
191
+atmega168: $(PROGRAM)_atmega168.lst
192
+
193
+atmega168_isp: atmega168
194
+atmega168_isp: TARGET = atmega168
195
+# 2.7V brownout
196
+atmega168_isp: HFUSE = DD
197
+# Low power xtal (16MHz) 16KCK/14CK+65ms
198
+atmega168_isp: LFUSE = FF
199
+# 512 byte boot
200
+atmega168_isp: EFUSE = 04
201
+atmega168_isp: isp
202
+
203
+diecimila: TARGET = diecimila
204
+diecimila: MCU_TARGET = atmega168
205
+diecimila: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
206
+diecimila: AVR_FREQ = 16000000L 
207
+diecimila: $(PROGRAM)_diecimila.hex
208
+diecimila: $(PROGRAM)_diecimila.lst
209
+
210
+diecimila_isp: diecimila
211
+diecimila_isp: TARGET = diecimila
212
+# 2.7V brownout
213
+diecimila_isp: HFUSE = DD
214
+# Low power xtal (16MHz) 16KCK/14CK+65ms
215
+diecimila_isp: LFUSE = FF
216
+# 512 byte boot
217
+diecimila_isp: EFUSE = 04
218
+diecimila_isp: isp
219
+
220
+atmega328: TARGET = atmega328
221
+atmega328: MCU_TARGET = atmega328p
222
+atmega328: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
223
+atmega328: AVR_FREQ = 16000000L
224
+atmega328: LDSECTIONS  = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
225
+atmega328: $(PROGRAM)_atmega328.hex
226
+atmega328: $(PROGRAM)_atmega328.lst
227
+
228
+atmega328_isp: atmega328
229
+atmega328_isp: TARGET = atmega328
230
+atmega328_isp: MCU_TARGET = atmega328p
231
+# 512 byte boot, SPIEN
232
+atmega328_isp: HFUSE = DE
233
+# Low power xtal (16MHz) 16KCK/14CK+65ms
234
+atmega328_isp: LFUSE = FF
235
+# 2.7V brownout
236
+atmega328_isp: EFUSE = 05
237
+atmega328_isp: isp
238
+
239
+atmega1284: TARGET = atmega1284p
240
+atmega1284: MCU_TARGET = atmega1284p
241
+atmega1284: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DBIGBOOT'
242
+atmega1284: AVR_FREQ = 16000000L
243
+atmega1284: LDSECTIONS  = -Wl,--section-start=.text=0x1fc00
244
+atmega1284: $(PROGRAM)_atmega1284p.hex
245
+atmega1284: $(PROGRAM)_atmega1284p.lst
246
+
247
+atmega1284_isp: atmega1284
248
+atmega1284_isp: TARGET = atmega1284p
249
+atmega1284_isp: MCU_TARGET = atmega1284p
250
+# 1024 byte boot
251
+atmega1284_isp: HFUSE = DE
252
+# Low power xtal (16MHz) 16KCK/14CK+65ms
253
+atmega1284_isp: LFUSE = FF
254
+# 2.7V brownout
255
+atmega1284_isp: EFUSE = FD
256
+atmega1284_isp: isp
257
+
258
+# Sanguino has a minimum boot size of 1024 bytes, so enable extra functions
259
+#
260
+sanguino: TARGET = atmega644p
261
+sanguino: MCU_TARGET = atmega644p
262
+sanguino: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DBIGBOOT'
263
+sanguino: AVR_FREQ = 16000000L
264
+sanguino: LDSECTIONS  = -Wl,--section-start=.text=0xfc00
265
+sanguino: $(PROGRAM)_atmega644p.hex
266
+sanguino: $(PROGRAM)_atmega644p.lst
267
+
268
+sanguino_isp: sanguino
269
+sanguino_isp: TARGET = atmega644p
270
+sanguino_isp: MCU_TARGET = atmega644p
271
+# 1024 byte boot
272
+sanguino_isp: HFUSE = DE
273
+# Low power xtal (16MHz) 16KCK/14CK+65ms
274
+sanguino_isp: LFUSE = FF
275
+# 2.7V brownout
276
+sanguino_isp: EFUSE = 05
277
+sanguino_isp: isp
278
+
279
+# Mega has a minimum boot size of 1024 bytes, so enable extra functions
280
+#mega: TARGET = atmega1280
281
+mega: MCU_TARGET = atmega1280
282
+mega: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200' '-DBIGBOOT'
283
+mega: AVR_FREQ = 16000000L
284
+mega: LDSECTIONS  = -Wl,--section-start=.text=0x1fc00
285
+mega: $(PROGRAM)_atmega1280.hex
286
+mega: $(PROGRAM)_atmega1280.lst
287
+
288
+mega_isp: mega
289
+mega_isp: TARGET = atmega1280
290
+mega_isp: MCU_TARGET = atmega1280
291
+# 1024 byte boot
292
+mega_isp: HFUSE = DE
293
+# Low power xtal (16MHz) 16KCK/14CK+65ms
294
+mega_isp: LFUSE = FF
295
+# 2.7V brownout
296
+mega_isp: EFUSE = 05
297
+mega_isp: isp
298
+
299
+# ATmega8
300
+#
301
+atmega8: TARGET = atmega8
302
+atmega8: MCU_TARGET = atmega8
303
+atmega8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
304
+atmega8: AVR_FREQ = 16000000L 
305
+atmega8: LDSECTIONS  = -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe
306
+atmega8: $(PROGRAM)_atmega8.hex
307
+atmega8: $(PROGRAM)_atmega8.lst
308
+
309
+atmega8_isp: atmega8
310
+atmega8_isp: TARGET = atmega8
311
+atmega8_isp: MCU_TARGET = atmega8
312
+# SPIEN, CKOPT, Bootsize=512B
313
+atmega8_isp: HFUSE = CC
314
+# 2.7V brownout, Low power xtal (16MHz) 16KCK/14CK+65ms
315
+atmega8_isp: LFUSE = BF
316
+atmega8_isp: isp
317
+
318
+# ATmega88
319
+#
320
+atmega88: TARGET = atmega88
321
+atmega88: MCU_TARGET = atmega88
322
+atmega88: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
323
+atmega88: AVR_FREQ = 16000000L 
324
+atmega88: LDSECTIONS  = -Wl,--section-start=.text=0x1e00 -Wl,--section-start=.version=0x1ffe
325
+atmega88: $(PROGRAM)_atmega88.hex
326
+atmega88: $(PROGRAM)_atmega88.lst
327
+
328
+atmega88_isp: atmega88
329
+atmega88_isp: TARGET = atmega88
330
+atmega88_isp: MCU_TARGET = atmega88
331
+# 2.7V brownout
332
+atmega88_isp: HFUSE = DD
333
+# Low power xtal (16MHz) 16KCK/14CK+65ms
334
+atemga88_isp: LFUSE = FF
335
+# 512 byte boot
336
+atmega88_isp: EFUSE = 04
337
+atmega88_isp: isp
338
+
339
+
340
+# 8MHz clocked platforms
341
+#
342
+# These are capable of 115200 baud
343
+#
344
+
345
+lilypad: TARGET = lilypad
346
+lilypad: MCU_TARGET = atmega168
347
+lilypad: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
348
+lilypad: AVR_FREQ = 8000000L
349
+lilypad: $(PROGRAM)_lilypad.hex
350
+lilypad: $(PROGRAM)_lilypad.lst
351
+
352
+lilypad_isp: lilypad
353
+lilypad_isp: TARGET = lilypad
354
+# 2.7V brownout
355
+lilypad_isp: HFUSE = DD
356
+# Internal 8MHz osc (8MHz) Slow rising power
357
+lilypad_isp: LFUSE = E2
358
+# 512 byte boot
359
+lilypad_isp: EFUSE = 04
360
+lilypad_isp: isp
361
+
362
+lilypad_resonator: TARGET = lilypad_resonator
363
+lilypad_resonator: MCU_TARGET = atmega168
364
+lilypad_resonator: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
365
+lilypad_resonator: AVR_FREQ = 8000000L
366
+lilypad_resonator: $(PROGRAM)_lilypad_resonator.hex
367
+lilypad_resonator: $(PROGRAM)_lilypad_resonator.lst
368
+
369
+lilypad_resonator_isp: lilypad_resonator
370
+lilypad_resonator_isp: TARGET = lilypad_resonator
371
+# 2.7V brownout
372
+lilypad_resonator_isp: HFUSE = DD
373
+# Full swing xtal (20MHz) 258CK/14CK+4.1ms
374
+lilypad_resonator_isp: LFUSE = C6
375
+# 512 byte boot
376
+lilypad_resonator_isp: EFUSE = 04
377
+lilypad_resonator_isp: isp
378
+
379
+pro8: TARGET = pro_8MHz
380
+pro8: MCU_TARGET = atmega168
381
+pro8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
382
+pro8: AVR_FREQ = 8000000L
383
+pro8: $(PROGRAM)_pro_8MHz.hex
384
+pro8: $(PROGRAM)_pro_8MHz.lst
385
+
386
+pro8_isp: pro8
387
+pro8_isp: TARGET = pro_8MHz
388
+# 2.7V brownout
389
+pro8_isp: HFUSE = DD
390
+# Full swing xtal (20MHz) 258CK/14CK+4.1ms
391
+pro8_isp: LFUSE = C6
392
+# 512 byte boot
393
+pro8_isp: EFUSE = 04
394
+pro8_isp: isp
395
+
396
+atmega328_pro8: TARGET = atmega328_pro_8MHz
397
+atmega328_pro8: MCU_TARGET = atmega328p
398
+atmega328_pro8: CFLAGS += '-DLED_START_FLASHES=3' '-DBAUD_RATE=115200'
399
+atmega328_pro8: AVR_FREQ = 8000000L
400
+atmega328_pro8: LDSECTIONS = -Wl,--section-start=.text=0x7e00 -Wl,--section-start=.version=0x7ffe
401
+atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.hex
402
+atmega328_pro8: $(PROGRAM)_atmega328_pro_8MHz.lst
403
+
404
+atmega328_pro8_isp: atmega328_pro8
405
+atmega328_pro8_isp: TARGET = atmega328_pro_8MHz
406
+atmega328_pro8_isp: MCU_TARGET = atmega328p
407
+# 512 byte boot, SPIEN
408
+atmega328_pro8_isp: HFUSE = DE
409
+# Low power xtal (16MHz) 16KCK/14CK+65ms
410
+atmega328_pro8_isp: LFUSE = FF
411
+# 2.7V brownout
412
+atmega328_pro8_isp: EFUSE = 05
413
+atmega328_pro8_isp: isp
414
+
415
+# 1MHz clocked platforms
416
+#
417
+# These are capable of 9600 baud
418
+#
419
+
420
+luminet: TARGET = luminet
421
+luminet: MCU_TARGET = attiny84
422
+luminet: CFLAGS += '-DLED_START_FLASHES=3' '-DSOFT_UART' '-DBAUD_RATE=9600'
423
+luminet: CFLAGS += '-DVIRTUAL_BOOT_PARTITION'
424
+luminet: AVR_FREQ = 1000000L
425
+luminet: LDSECTIONS = -Wl,--section-start=.text=0x1d00 -Wl,--section-start=.version=0x1efe
426
+luminet: $(PROGRAM)_luminet.hex
427
+luminet: $(PROGRAM)_luminet.lst
428
+
429
+luminet_isp: luminet
430
+luminet_isp: TARGET = luminet
431
+luminet_isp: MCU_TARGET = attiny84
432
+# Brownout disabled
433
+luminet_isp: HFUSE = DF
434
+# 1MHz internal oscillator, slowly rising power
435
+luminet_isp: LFUSE = 62
436
+# Self-programming enable
437
+luminet_isp: EFUSE = FE
438
+luminet_isp: isp
439
+
440
+#
441
+# Generic build instructions
442
+#
443
+#
444
+
445
+isp: $(TARGET)
446
+        $(ISPFUSES)
447
+        $(ISPFLASH)
448
+
449
+isp-stk500: $(PROGRAM)_$(TARGET).hex
450
+        $(STK500-1)
451
+        $(STK500-2)
452
+
453
+%.elf: $(OBJ)
454
+        $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
455
+        $(SIZE) $@
456
+
457
+clean:
458
+        rm -rf *.o *.elf *.lst *.map *.sym *.lss *.eep *.srec *.bin *.hex
459
+
460
+%.lst: %.elf
461
+        $(OBJDUMP) -h -S $< > $@
462
+
463
+%.hex: %.elf
464
+        $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O ihex $< $@
465
+
466
+%.srec: %.elf
467
+        $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O srec $< $@
468
+
469
+%.bin: %.elf
470
+        $(OBJCOPY) -j .text -j .data -j .version --set-section-flags .version=alloc,load -O binary $< $@

+ 848
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega1284p/boot.h ファイルの表示

@@ -0,0 +1,848 @@
1
+/* Modified to use out for SPM access
2
+** Peter Knight, Optiboot project http://optiboot.googlecode.com
3
+**
4
+** Todo: Tidy up
5
+**
6
+** "_short" routines execute 1 cycle faster and use 1 less word of flash
7
+** by using "out" instruction instead of "sts".
8
+**
9
+** Additional elpm variants that trust the value of RAMPZ
10
+*/
11
+
12
+/* Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007  Eric B. Weddington
13
+   All rights reserved.
14
+
15
+   Redistribution and use in source and binary forms, with or without
16
+   modification, are permitted provided that the following conditions are met:
17
+
18
+   * Redistributions of source code must retain the above copyright
19
+     notice, this list of conditions and the following disclaimer.
20
+   * Redistributions in binary form must reproduce the above copyright
21
+     notice, this list of conditions and the following disclaimer in
22
+     the documentation and/or other materials provided with the
23
+     distribution.
24
+   * Neither the name of the copyright holders nor the names of
25
+     contributors may be used to endorse or promote products derived
26
+     from this software without specific prior written permission.
27
+
28
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29
+  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30
+  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31
+  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
32
+  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33
+  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34
+  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35
+  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36
+  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37
+  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38
+  POSSIBILITY OF SUCH DAMAGE. */
39
+
40
+/* $Id: boot.h,v 1.27.2.3 2008/09/30 13:58:48 arcanum Exp $ */
41
+
42
+#ifndef _AVR_BOOT_H_
43
+#define _AVR_BOOT_H_    1
44
+
45
+/** \file */
46
+/** \defgroup avr_boot <avr/boot.h>: Bootloader Support Utilities
47
+    \code
48
+    #include <avr/io.h>
49
+    #include <avr/boot.h>
50
+    \endcode
51
+
52
+    The macros in this module provide a C language interface to the
53
+    bootloader support functionality of certain AVR processors. These
54
+    macros are designed to work with all sizes of flash memory.
55
+
56
+    Global interrupts are not automatically disabled for these macros. It
57
+    is left up to the programmer to do this. See the code example below. 
58
+    Also see the processor datasheet for caveats on having global interrupts 
59
+    enabled during writing of the Flash.
60
+
61
+    \note Not all AVR processors provide bootloader support. See your
62
+    processor datasheet to see if it provides bootloader support.
63
+
64
+    \todo From email with Marek: On smaller devices (all except ATmega64/128),
65
+    __SPM_REG is in the I/O space, accessible with the shorter "in" and "out"
66
+    instructions - since the boot loader has a limited size, this could be an
67
+    important optimization.
68
+
69
+    \par API Usage Example
70
+    The following code shows typical usage of the boot API.
71
+
72
+    \code
73
+    #include <inttypes.h>
74
+    #include <avr/interrupt.h>
75
+    #include <avr/pgmspace.h>
76
+    
77
+    void boot_program_page (uint32_t page, uint8_t *buf)
78
+    {
79
+        uint16_t i;
80
+        uint8_t sreg;
81
+
82
+        // Disable interrupts.
83
+
84
+        sreg = SREG;
85
+        cli();
86
+    
87
+        eeprom_busy_wait ();
88
+
89
+        boot_page_erase (page);
90
+        boot_spm_busy_wait ();      // Wait until the memory is erased.
91
+
92
+        for (i=0; i<SPM_PAGESIZE; i+=2)
93
+        {
94
+            // Set up little-endian word.
95
+
96
+            uint16_t w = *buf++;
97
+            w += (*buf++) << 8;
98
+        
99
+            boot_page_fill (page + i, w);
100
+        }
101
+
102
+        boot_page_write (page);     // Store buffer in flash page.
103
+        boot_spm_busy_wait();       // Wait until the memory is written.
104
+
105
+        // Reenable RWW-section again. We need this if we want to jump back
106
+        // to the application after bootloading.
107
+
108
+        boot_rww_enable ();
109
+
110
+        // Re-enable interrupts (if they were ever enabled).
111
+
112
+        SREG = sreg;
113
+    }\endcode */
114
+
115
+#include <avr/eeprom.h>
116
+#include <avr/io.h>
117
+#include <inttypes.h>
118
+#include <limits.h>
119
+
120
+/* Check for SPM Control Register in processor. */
121
+#if defined (SPMCSR)
122
+#  define __SPM_REG    SPMCSR
123
+#elif defined (SPMCR)
124
+#  define __SPM_REG    SPMCR
125
+#else
126
+#  error AVR processor does not provide bootloader support!
127
+#endif
128
+
129
+
130
+/* Check for SPM Enable bit. */
131
+#if defined(SPMEN)
132
+#  define __SPM_ENABLE  SPMEN
133
+#elif defined(SELFPRGEN)
134
+#  define __SPM_ENABLE  SELFPRGEN
135
+#else
136
+#  error Cannot find SPM Enable bit definition!
137
+#endif
138
+
139
+/** \ingroup avr_boot
140
+    \def BOOTLOADER_SECTION
141
+
142
+    Used to declare a function or variable to be placed into a
143
+    new section called .bootloader. This section and its contents
144
+    can then be relocated to any address (such as the bootloader
145
+    NRWW area) at link-time. */
146
+
147
+#define BOOTLOADER_SECTION    __attribute__ ((section (".bootloader")))
148
+
149
+/* Create common bit definitions. */
150
+#ifdef ASB
151
+#define __COMMON_ASB    ASB
152
+#else
153
+#define __COMMON_ASB    RWWSB
154
+#endif
155
+
156
+#ifdef ASRE
157
+#define __COMMON_ASRE   ASRE
158
+#else
159
+#define __COMMON_ASRE   RWWSRE
160
+#endif
161
+
162
+/* Define the bit positions of the Boot Lock Bits. */
163
+
164
+#define BLB12           5
165
+#define BLB11           4
166
+#define BLB02           3
167
+#define BLB01           2
168
+
169
+/** \ingroup avr_boot
170
+    \def boot_spm_interrupt_enable()
171
+    Enable the SPM interrupt. */
172
+
173
+#define boot_spm_interrupt_enable()   (__SPM_REG |= (uint8_t)_BV(SPMIE))
174
+
175
+/** \ingroup avr_boot
176
+    \def boot_spm_interrupt_disable()
177
+    Disable the SPM interrupt. */
178
+
179
+#define boot_spm_interrupt_disable()  (__SPM_REG &= (uint8_t)~_BV(SPMIE))
180
+
181
+/** \ingroup avr_boot
182
+    \def boot_is_spm_interrupt()
183
+    Check if the SPM interrupt is enabled. */
184
+
185
+#define boot_is_spm_interrupt()       (__SPM_REG & (uint8_t)_BV(SPMIE))
186
+
187
+/** \ingroup avr_boot
188
+    \def boot_rww_busy()
189
+    Check if the RWW section is busy. */
190
+
191
+#define boot_rww_busy()          (__SPM_REG & (uint8_t)_BV(__COMMON_ASB))
192
+
193
+/** \ingroup avr_boot
194
+    \def boot_spm_busy()
195
+    Check if the SPM instruction is busy. */
196
+
197
+#define boot_spm_busy()               (__SPM_REG & (uint8_t)_BV(__SPM_ENABLE))
198
+
199
+/** \ingroup avr_boot
200
+    \def boot_spm_busy_wait()
201
+    Wait while the SPM instruction is busy. */
202
+
203
+#define boot_spm_busy_wait()          do{}while(boot_spm_busy())
204
+
205
+#define __BOOT_PAGE_ERASE         (_BV(__SPM_ENABLE) | _BV(PGERS))
206
+#define __BOOT_PAGE_WRITE         (_BV(__SPM_ENABLE) | _BV(PGWRT))
207
+#define __BOOT_PAGE_FILL          _BV(__SPM_ENABLE)
208
+#define __BOOT_RWW_ENABLE         (_BV(__SPM_ENABLE) | _BV(__COMMON_ASRE))
209
+#define __BOOT_LOCK_BITS_SET      (_BV(__SPM_ENABLE) | _BV(BLBSET))
210
+
211
+#define __boot_page_fill_short(address, data)   \
212
+(__extension__({                                 \
213
+    __asm__ __volatile__                         \
214
+    (                                            \
215
+        "movw  r0, %3\n\t"                       \
216
+        "out %0, %1\n\t"                         \
217
+        "spm\n\t"                                \
218
+        "clr  r1\n\t"                            \
219
+        :                                        \
220
+        : "i" (_SFR_IO_ADDR(__SPM_REG)),        \
221
+          "r" ((uint8_t)__BOOT_PAGE_FILL),       \
222
+          "z" ((uint16_t)address),               \
223
+          "r" ((uint16_t)data)                   \
224
+        : "r0"                                   \
225
+    );                                           \
226
+}))
227
+
228
+#define __boot_page_fill_normal(address, data)   \
229
+(__extension__({                                 \
230
+    __asm__ __volatile__                         \
231
+    (                                            \
232
+        "movw  r0, %3\n\t"                       \
233
+        "sts %0, %1\n\t"                         \
234
+        "spm\n\t"                                \
235
+        "clr  r1\n\t"                            \
236
+        :                                        \
237
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
238
+          "r" ((uint8_t)__BOOT_PAGE_FILL),       \
239
+          "z" ((uint16_t)address),               \
240
+          "r" ((uint16_t)data)                   \
241
+        : "r0"                                   \
242
+    );                                           \
243
+}))
244
+
245
+#define __boot_page_fill_alternate(address, data)\
246
+(__extension__({                                 \
247
+    __asm__ __volatile__                         \
248
+    (                                            \
249
+        "movw  r0, %3\n\t"                       \
250
+        "sts %0, %1\n\t"                         \
251
+        "spm\n\t"                                \
252
+        ".word 0xffff\n\t"                       \
253
+        "nop\n\t"                                \
254
+        "clr  r1\n\t"                            \
255
+        :                                        \
256
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
257
+          "r" ((uint8_t)__BOOT_PAGE_FILL),       \
258
+          "z" ((uint16_t)address),               \
259
+          "r" ((uint16_t)data)                   \
260
+        : "r0"                                   \
261
+    );                                           \
262
+}))
263
+
264
+#define __boot_page_fill_extended(address, data) \
265
+(__extension__({                                 \
266
+    __asm__ __volatile__                         \
267
+    (                                            \
268
+        "movw  r0, %4\n\t"                       \
269
+        "movw r30, %A3\n\t"                      \
270
+        "sts %1, %C3\n\t"                        \
271
+        "sts %0, %2\n\t"                         \
272
+        "spm\n\t"                                \
273
+        "clr  r1\n\t"                            \
274
+        :                                        \
275
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
276
+          "i" (_SFR_MEM_ADDR(RAMPZ)),            \
277
+          "r" ((uint8_t)__BOOT_PAGE_FILL),       \
278
+          "r" ((uint32_t)address),               \
279
+          "r" ((uint16_t)data)                   \
280
+        : "r0", "r30", "r31"                     \
281
+    );                                           \
282
+}))
283
+
284
+#define __boot_page_fill_extended_short(address, data) \
285
+(__extension__({                                 \
286
+    __asm__ __volatile__                         \
287
+    (                                            \
288
+        "movw  r0, %4\n\t"                       \
289
+        "movw r30, %A3\n\t"                      \
290
+        "out %1, %C3\n\t"                        \
291
+        "out %0, %2\n\t"                         \
292
+        "spm\n\t"                                \
293
+        "clr  r1\n\t"                            \
294
+        :                                        \
295
+        : "i" (_SFR_IO_ADDR(__SPM_REG)),        \
296
+          "i" (_SFR_IO_ADDR(RAMPZ)),            \
297
+          "r" ((uint8_t)__BOOT_PAGE_FILL),       \
298
+          "r" ((uint32_t)address),               \
299
+          "r" ((uint16_t)data)                   \
300
+        : "r0", "r30", "r31"                     \
301
+    );                                           \
302
+}))
303
+
304
+#define __boot_page_erase_short(address)        \
305
+(__extension__({                                 \
306
+    __asm__ __volatile__                         \
307
+    (                                            \
308
+        "out %0, %1\n\t"                         \
309
+        "spm\n\t"                                \
310
+        :                                        \
311
+        : "i" (_SFR_IO_ADDR(__SPM_REG)),        \
312
+          "r" ((uint8_t)__BOOT_PAGE_ERASE),      \
313
+          "z" ((uint16_t)address)                \
314
+    );                                           \
315
+}))
316
+
317
+
318
+#define __boot_page_erase_normal(address)        \
319
+(__extension__({                                 \
320
+    __asm__ __volatile__                         \
321
+    (                                            \
322
+        "sts %0, %1\n\t"                         \
323
+        "spm\n\t"                                \
324
+        :                                        \
325
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
326
+          "r" ((uint8_t)__BOOT_PAGE_ERASE),      \
327
+          "z" ((uint16_t)address)                \
328
+    );                                           \
329
+}))
330
+
331
+#define __boot_page_erase_alternate(address)     \
332
+(__extension__({                                 \
333
+    __asm__ __volatile__                         \
334
+    (                                            \
335
+        "sts %0, %1\n\t"                         \
336
+        "spm\n\t"                                \
337
+        ".word 0xffff\n\t"                       \
338
+        "nop\n\t"                                \
339
+        :                                        \
340
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
341
+          "r" ((uint8_t)__BOOT_PAGE_ERASE),      \
342
+          "z" ((uint16_t)address)                \
343
+    );                                           \
344
+}))
345
+
346
+#define __boot_page_erase_extended(address)      \
347
+(__extension__({                                 \
348
+    __asm__ __volatile__                         \
349
+    (                                            \
350
+        "movw r30, %A3\n\t"                      \
351
+        "sts  %1, %C3\n\t"                       \
352
+        "sts %0, %2\n\t"                         \
353
+        "spm\n\t"                                \
354
+        :                                        \
355
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
356
+          "i" (_SFR_MEM_ADDR(RAMPZ)),            \
357
+          "r" ((uint8_t)__BOOT_PAGE_ERASE),      \
358
+          "r" ((uint32_t)address)                \
359
+        : "r30", "r31"                           \
360
+    );                                           \
361
+}))
362
+#define __boot_page_erase_extended_short(address)      \
363
+(__extension__({                                 \
364
+    __asm__ __volatile__                         \
365
+    (                                            \
366
+        "movw r30, %A3\n\t"                      \
367
+        "out  %1, %C3\n\t"                       \
368
+        "out %0, %2\n\t"                         \
369
+        "spm\n\t"                                \
370
+        :                                        \
371
+        : "i" (_SFR_IO_ADDR(__SPM_REG)),        \
372
+          "i" (_SFR_IO_ADDR(RAMPZ)),            \
373
+          "r" ((uint8_t)__BOOT_PAGE_ERASE),      \
374
+          "r" ((uint32_t)address)                \
375
+        : "r30", "r31"                           \
376
+    );                                           \
377
+}))
378
+
379
+#define __boot_page_write_short(address)        \
380
+(__extension__({                                 \
381
+    __asm__ __volatile__                         \
382
+    (                                            \
383
+        "out %0, %1\n\t"                         \
384
+        "spm\n\t"                                \
385
+        :                                        \
386
+        : "i" (_SFR_IO_ADDR(__SPM_REG)),        \
387
+          "r" ((uint8_t)__BOOT_PAGE_WRITE),      \
388
+          "z" ((uint16_t)address)                \
389
+    );                                           \
390
+}))
391
+
392
+#define __boot_page_write_normal(address)        \
393
+(__extension__({                                 \
394
+    __asm__ __volatile__                         \
395
+    (                                            \
396
+        "sts %0, %1\n\t"                         \
397
+        "spm\n\t"                                \
398
+        :                                        \
399
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
400
+          "r" ((uint8_t)__BOOT_PAGE_WRITE),      \
401
+          "z" ((uint16_t)address)                \
402
+    );                                           \
403
+}))
404
+
405
+#define __boot_page_write_alternate(address)     \
406
+(__extension__({                                 \
407
+    __asm__ __volatile__                         \
408
+    (                                            \
409
+        "sts %0, %1\n\t"                         \
410
+        "spm\n\t"                                \
411
+        ".word 0xffff\n\t"                       \
412
+        "nop\n\t"                                \
413
+        :                                        \
414
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
415
+          "r" ((uint8_t)__BOOT_PAGE_WRITE),      \
416
+          "z" ((uint16_t)address)                \
417
+    );                                           \
418
+}))
419
+
420
+#define __boot_page_write_extended(address)      \
421
+(__extension__({                                 \
422
+    __asm__ __volatile__                         \
423
+    (                                            \
424
+        "movw r30, %A3\n\t"                      \
425
+        "sts %1, %C3\n\t"                        \
426
+        "sts %0, %2\n\t"                         \
427
+        "spm\n\t"                                \
428
+        :                                        \
429
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
430
+          "i" (_SFR_MEM_ADDR(RAMPZ)),            \
431
+          "r" ((uint8_t)__BOOT_PAGE_WRITE),      \
432
+          "r" ((uint32_t)address)                \
433
+        : "r30", "r31"                           \
434
+    );                                           \
435
+}))
436
+#define __boot_page_write_extended_short(address)      \
437
+(__extension__({                                 \
438
+    __asm__ __volatile__                         \
439
+    (                                            \
440
+        "movw r30, %A3\n\t"                      \
441
+        "out %1, %C3\n\t"                        \
442
+        "out %0, %2\n\t"                         \
443
+        "spm\n\t"                                \
444
+        :                                        \
445
+        : "i" (_SFR_IO_ADDR(__SPM_REG)),        \
446
+          "i" (_SFR_IO_ADDR(RAMPZ)),            \
447
+          "r" ((uint8_t)__BOOT_PAGE_WRITE),      \
448
+          "r" ((uint32_t)address)                \
449
+        : "r30", "r31"                           \
450
+    );                                           \
451
+}))
452
+
453
+#define __boot_rww_enable_short()                      \
454
+(__extension__({                                 \
455
+    __asm__ __volatile__                         \
456
+    (                                            \
457
+        "out %0, %1\n\t"                         \
458
+        "spm\n\t"                                \
459
+        :                                        \
460
+        : "i" (_SFR_IO_ADDR(__SPM_REG)),        \
461
+          "r" ((uint8_t)__BOOT_RWW_ENABLE)       \
462
+    );                                           \
463
+}))
464
+
465
+#define __boot_rww_enable()                      \
466
+(__extension__({                                 \
467
+    __asm__ __volatile__                         \
468
+    (                                            \
469
+        "sts %0, %1\n\t"                         \
470
+        "spm\n\t"                                \
471
+        :                                        \
472
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
473
+          "r" ((uint8_t)__BOOT_RWW_ENABLE)       \
474
+    );                                           \
475
+}))
476
+
477
+#define __boot_rww_enable_alternate()            \
478
+(__extension__({                                 \
479
+    __asm__ __volatile__                         \
480
+    (                                            \
481
+        "sts %0, %1\n\t"                         \
482
+        "spm\n\t"                                \
483
+        ".word 0xffff\n\t"                       \
484
+        "nop\n\t"                                \
485
+        :                                        \
486
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),        \
487
+          "r" ((uint8_t)__BOOT_RWW_ENABLE)       \
488
+    );                                           \
489
+}))
490
+
491
+/* From the mega16/mega128 data sheets (maybe others):
492
+
493
+     Bits by SPM To set the Boot Loader Lock bits, write the desired data to
494
+     R0, write "X0001001" to SPMCR and execute SPM within four clock cycles
495
+     after writing SPMCR. The only accessible Lock bits are the Boot Lock bits
496
+     that may prevent the Application and Boot Loader section from any
497
+     software update by the MCU.
498
+
499
+     If bits 5..2 in R0 are cleared (zero), the corresponding Boot Lock bit
500
+     will be programmed if an SPM instruction is executed within four cycles
501
+     after BLBSET and SPMEN (or SELFPRGEN) are set in SPMCR. The Z-pointer is 
502
+     don't care during this operation, but for future compatibility it is 
503
+     recommended to load the Z-pointer with $0001 (same as used for reading the 
504
+     Lock bits). For future compatibility It is also recommended to set bits 7, 
505
+     6, 1, and 0 in R0 to 1 when writing the Lock bits. When programming the 
506
+     Lock bits the entire Flash can be read during the operation. */
507
+
508
+#define __boot_lock_bits_set_short(lock_bits)                    \
509
+(__extension__({                                           \
510
+    uint8_t value = (uint8_t)(~(lock_bits));               \
511
+    __asm__ __volatile__                                   \
512
+    (                                                      \
513
+        "ldi r30, 1\n\t"                                   \
514
+        "ldi r31, 0\n\t"                                   \
515
+        "mov r0, %2\n\t"                                   \
516
+        "out %0, %1\n\t"                                   \
517
+        "spm\n\t"                                          \
518
+        :                                                  \
519
+        : "i" (_SFR_IO_ADDR(__SPM_REG)),                  \
520
+          "r" ((uint8_t)__BOOT_LOCK_BITS_SET),             \
521
+          "r" (value)                                      \
522
+        : "r0", "r30", "r31"                               \
523
+    );                                                     \
524
+}))
525
+
526
+#define __boot_lock_bits_set(lock_bits)                    \
527
+(__extension__({                                           \
528
+    uint8_t value = (uint8_t)(~(lock_bits));               \
529
+    __asm__ __volatile__                                   \
530
+    (                                                      \
531
+        "ldi r30, 1\n\t"                                   \
532
+        "ldi r31, 0\n\t"                                   \
533
+        "mov r0, %2\n\t"                                   \
534
+        "sts %0, %1\n\t"                                   \
535
+        "spm\n\t"                                          \
536
+        :                                                  \
537
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),                  \
538
+          "r" ((uint8_t)__BOOT_LOCK_BITS_SET),             \
539
+          "r" (value)                                      \
540
+        : "r0", "r30", "r31"                               \
541
+    );                                                     \
542
+}))
543
+
544
+#define __boot_lock_bits_set_alternate(lock_bits)          \
545
+(__extension__({                                           \
546
+    uint8_t value = (uint8_t)(~(lock_bits));               \
547
+    __asm__ __volatile__                                   \
548
+    (                                                      \
549
+        "ldi r30, 1\n\t"                                   \
550
+        "ldi r31, 0\n\t"                                   \
551
+        "mov r0, %2\n\t"                                   \
552
+        "sts %0, %1\n\t"                                   \
553
+        "spm\n\t"                                          \
554
+        ".word 0xffff\n\t"                                 \
555
+        "nop\n\t"                                          \
556
+        :                                                  \
557
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),                  \
558
+          "r" ((uint8_t)__BOOT_LOCK_BITS_SET),             \
559
+          "r" (value)                                      \
560
+        : "r0", "r30", "r31"                               \
561
+    );                                                     \
562
+}))
563
+
564
+/*
565
+   Reading lock and fuse bits:
566
+
567
+     Similarly to writing the lock bits above, set BLBSET and SPMEN (or 
568
+     SELFPRGEN) bits in __SPMREG, and then (within four clock cycles) issue an 
569
+     LPM instruction.
570
+
571
+     Z address:       contents:
572
+     0x0000           low fuse bits
573
+     0x0001           lock bits
574
+     0x0002           extended fuse bits
575
+     0x0003           high fuse bits
576
+
577
+     Sounds confusing, doesn't it?
578
+
579
+     Unlike the macros in pgmspace.h, no need to care for non-enhanced
580
+     cores here as these old cores do not provide SPM support anyway.
581
+ */
582
+
583
+/** \ingroup avr_boot
584
+    \def GET_LOW_FUSE_BITS
585
+    address to read the low fuse bits, using boot_lock_fuse_bits_get
586
+ */
587
+#define GET_LOW_FUSE_BITS           (0x0000)
588
+/** \ingroup avr_boot
589
+    \def GET_LOCK_BITS
590
+    address to read the lock bits, using boot_lock_fuse_bits_get
591
+ */
592
+#define GET_LOCK_BITS               (0x0001)
593
+/** \ingroup avr_boot
594
+    \def GET_EXTENDED_FUSE_BITS
595
+    address to read the extended fuse bits, using boot_lock_fuse_bits_get
596
+ */
597
+#define GET_EXTENDED_FUSE_BITS      (0x0002)
598
+/** \ingroup avr_boot
599
+    \def GET_HIGH_FUSE_BITS
600
+    address to read the high fuse bits, using boot_lock_fuse_bits_get
601
+ */
602
+#define GET_HIGH_FUSE_BITS          (0x0003)
603
+
604
+/** \ingroup avr_boot
605
+    \def boot_lock_fuse_bits_get(address)
606
+
607
+    Read the lock or fuse bits at \c address.
608
+
609
+    Parameter \c address can be any of GET_LOW_FUSE_BITS,
610
+    GET_LOCK_BITS, GET_EXTENDED_FUSE_BITS, or GET_HIGH_FUSE_BITS.
611
+
612
+    \note The lock and fuse bits returned are the physical values,
613
+    i.e. a bit returned as 0 means the corresponding fuse or lock bit
614
+    is programmed.
615
+ */
616
+#define boot_lock_fuse_bits_get_short(address)                   \
617
+(__extension__({                                           \
618
+    uint8_t __result;                                      \
619
+    __asm__ __volatile__                                   \
620
+    (                                                      \
621
+        "ldi r30, %3\n\t"                                  \
622
+        "ldi r31, 0\n\t"                                   \
623
+        "out %1, %2\n\t"                                   \
624
+        "lpm %0, Z\n\t"                                    \
625
+        : "=r" (__result)                                  \
626
+        : "i" (_SFR_IO_ADDR(__SPM_REG)),                  \
627
+          "r" ((uint8_t)__BOOT_LOCK_BITS_SET),             \
628
+          "M" (address)                                    \
629
+        : "r0", "r30", "r31"                               \
630
+    );                                                     \
631
+    __result;                                              \
632
+}))
633
+
634
+#define boot_lock_fuse_bits_get(address)                   \
635
+(__extension__({                                           \
636
+    uint8_t __result;                                      \
637
+    __asm__ __volatile__                                   \
638
+    (                                                      \
639
+        "ldi r30, %3\n\t"                                  \
640
+        "ldi r31, 0\n\t"                                   \
641
+        "sts %1, %2\n\t"                                   \
642
+        "lpm %0, Z\n\t"                                    \
643
+        : "=r" (__result)                                  \
644
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),                  \
645
+          "r" ((uint8_t)__BOOT_LOCK_BITS_SET),             \
646
+          "M" (address)                                    \
647
+        : "r0", "r30", "r31"                               \
648
+    );                                                     \
649
+    __result;                                              \
650
+}))
651
+
652
+/** \ingroup avr_boot
653
+    \def boot_signature_byte_get(address)
654
+
655
+    Read the Signature Row byte at \c address.  For some MCU types,
656
+    this function can also retrieve the factory-stored oscillator
657
+    calibration bytes.
658
+
659
+    Parameter \c address can be 0-0x1f as documented by the datasheet.
660
+    \note The values are MCU type dependent.
661
+*/
662
+
663
+#define __BOOT_SIGROW_READ (_BV(__SPM_ENABLE) | _BV(SIGRD))
664
+
665
+#define boot_signature_byte_get_short(addr) \
666
+(__extension__({                      \
667
+      uint16_t __addr16 = (uint16_t)(addr);     \
668
+      uint8_t __result;                         \
669
+      __asm__ __volatile__                      \
670
+      (                                         \
671
+        "out %1, %2\n\t"                        \
672
+        "lpm %0, Z" "\n\t"                      \
673
+        : "=r" (__result)                       \
674
+        : "i" (_SFR_IO_ADDR(__SPM_REG)),        \
675
+          "r" ((uint8_t) __BOOT_SIGROW_READ),   \
676
+          "z" (__addr16)                        \
677
+      );                                        \
678
+      __result;                                 \
679
+}))
680
+
681
+#define boot_signature_byte_get(addr) \
682
+(__extension__({                      \
683
+      uint16_t __addr16 = (uint16_t)(addr);     \
684
+      uint8_t __result;                         \
685
+      __asm__ __volatile__                      \
686
+      (                                         \
687
+        "sts %1, %2\n\t"                        \
688
+        "lpm %0, Z" "\n\t"                      \
689
+        : "=r" (__result)                       \
690
+        : "i" (_SFR_MEM_ADDR(__SPM_REG)),       \
691
+          "r" ((uint8_t) __BOOT_SIGROW_READ),   \
692
+          "z" (__addr16)                        \
693
+      );                                        \
694
+      __result;                                 \
695
+}))
696
+
697
+/** \ingroup avr_boot
698
+    \def boot_page_fill(address, data)
699
+
700
+    Fill the bootloader temporary page buffer for flash 
701
+    address with data word. 
702
+
703
+    \note The address is a byte address. The data is a word. The AVR 
704
+    writes data to the buffer a word at a time, but addresses the buffer
705
+    per byte! So, increment your address by 2 between calls, and send 2
706
+    data bytes in a word format! The LSB of the data is written to the lower 
707
+    address; the MSB of the data is written to the higher address.*/
708
+
709
+/** \ingroup avr_boot
710
+    \def boot_page_erase(address)
711
+
712
+    Erase the flash page that contains address.
713
+
714
+    \note address is a byte address in flash, not a word address. */
715
+
716
+/** \ingroup avr_boot
717
+    \def boot_page_write(address)
718
+
719
+    Write the bootloader temporary page buffer 
720
+    to flash page that contains address.
721
+    
722
+    \note address is a byte address in flash, not a word address. */
723
+
724
+/** \ingroup avr_boot
725
+    \def boot_rww_enable()
726
+
727
+    Enable the Read-While-Write memory section. */
728
+
729
+/** \ingroup avr_boot
730
+    \def boot_lock_bits_set(lock_bits)
731
+
732
+    Set the bootloader lock bits.
733
+
734
+    \param lock_bits A mask of which Boot Loader Lock Bits to set.
735
+
736
+    \note In this context, a 'set bit' will be written to a zero value.
737
+    Note also that only BLBxx bits can be programmed by this command.
738
+
739
+    For example, to disallow the SPM instruction from writing to the Boot
740
+    Loader memory section of flash, you would use this macro as such:
741
+
742
+    \code
743
+    boot_lock_bits_set (_BV (BLB11));
744
+    \endcode
745
+
746
+    \note Like any lock bits, the Boot Loader Lock Bits, once set,
747
+    cannot be cleared again except by a chip erase which will in turn
748
+    also erase the boot loader itself. */
749
+
750
+/* Normal versions of the macros use 16-bit addresses.
751
+   Extended versions of the macros use 32-bit addresses.
752
+   Alternate versions of the macros use 16-bit addresses and require special
753
+   instruction sequences after LPM.
754
+
755
+   FLASHEND is defined in the ioXXXX.h file.
756
+   USHRT_MAX is defined in <limits.h>. */ 
757
+
758
+#if defined(__AVR_ATmega161__) || defined(__AVR_ATmega163__) \
759
+    || defined(__AVR_ATmega323__)
760
+
761
+/* Alternate: ATmega161/163/323 and 16 bit address */
762
+#define boot_page_fill(address, data) __boot_page_fill_alternate(address, data)
763
+#define boot_page_erase(address)      __boot_page_erase_alternate(address)
764
+#define boot_page_write(address)      __boot_page_write_alternate(address)
765
+#define boot_rww_enable()             __boot_rww_enable_alternate()
766
+#define boot_lock_bits_set(lock_bits) __boot_lock_bits_set_alternate(lock_bits)
767
+
768
+#elif (FLASHEND > USHRT_MAX)
769
+
770
+/* Extended: >16 bit address */
771
+#define boot_page_fill(address, data) __boot_page_fill_extended_short(address, data)
772
+#define boot_page_erase(address)      __boot_page_erase_extended_short(address)
773
+#define boot_page_write(address)      __boot_page_write_extended_short(address)
774
+#define boot_rww_enable()             __boot_rww_enable_short()
775
+#define boot_lock_bits_set(lock_bits) __boot_lock_bits_set_short(lock_bits)
776
+
777
+#else
778
+
779
+/* Normal: 16 bit address */
780
+#define boot_page_fill(address, data) __boot_page_fill_short(address, data)
781
+#define boot_page_erase(address)      __boot_page_erase_short(address)
782
+#define boot_page_write(address)      __boot_page_write_short(address)
783
+#define boot_rww_enable()             __boot_rww_enable_short()
784
+#define boot_lock_bits_set(lock_bits) __boot_lock_bits_set_short(lock_bits)
785
+
786
+#endif
787
+
788
+/** \ingroup avr_boot
789
+
790
+    Same as boot_page_fill() except it waits for eeprom and spm operations to
791
+    complete before filling the page. */
792
+
793
+#define boot_page_fill_safe(address, data) \
794
+do { \
795
+    boot_spm_busy_wait();                       \
796
+    eeprom_busy_wait();                         \
797
+    boot_page_fill(address, data);              \
798
+} while (0)
799
+
800
+/** \ingroup avr_boot
801
+
802
+    Same as boot_page_erase() except it waits for eeprom and spm operations to
803
+    complete before erasing the page. */
804
+
805
+#define boot_page_erase_safe(address) \
806
+do { \
807
+    boot_spm_busy_wait();                       \
808
+    eeprom_busy_wait();                         \
809
+    boot_page_erase (address);                  \
810
+} while (0)
811
+
812
+/** \ingroup avr_boot
813
+
814
+    Same as boot_page_write() except it waits for eeprom and spm operations to
815
+    complete before writing the page. */
816
+
817
+#define boot_page_write_safe(address) \
818
+do { \
819
+    boot_spm_busy_wait();                       \
820
+    eeprom_busy_wait();                         \
821
+    boot_page_write (address);                  \
822
+} while (0)
823
+
824
+/** \ingroup avr_boot
825
+
826
+    Same as boot_rww_enable() except waits for eeprom and spm operations to
827
+    complete before enabling the RWW mameory. */
828
+
829
+#define boot_rww_enable_safe() \
830
+do { \
831
+    boot_spm_busy_wait();                       \
832
+    eeprom_busy_wait();                         \
833
+    boot_rww_enable();                          \
834
+} while (0)
835
+
836
+/** \ingroup avr_boot
837
+
838
+    Same as boot_lock_bits_set() except waits for eeprom and spm operations to
839
+    complete before setting the lock bits. */
840
+
841
+#define boot_lock_bits_set_safe(lock_bits) \
842
+do { \
843
+    boot_spm_busy_wait();                       \
844
+    eeprom_busy_wait();                         \
845
+    boot_lock_bits_set (lock_bits);             \
846
+} while (0)
847
+
848
+#endif /* _AVR_BOOT_H_ */

+ 724
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega1284p/optiboot.c ファイルの表示

@@ -0,0 +1,724 @@
1
+/**********************************************************/
2
+/* -Wl,-section-start=bootloader=0x1fc00 */
3
+/* Optiboot bootloader for Arduino                        */
4
+/*                                                        */
5
+/* http://optiboot.googlecode.com                         */
6
+/*                                                        */
7
+/* Arduino-maintained version : See README.TXT            */
8
+/* http://code.google.com/p/arduino/                      */
9
+/*                                                        */
10
+/* Heavily optimised bootloader that is faster and        */
11
+/* smaller than the Arduino standard bootloader           */
12
+/*                                                        */
13
+/* Enhancements:                                          */
14
+/*   Fits in 512 bytes, saving 1.5K of code space         */
15
+/*   Background page erasing speeds up programming        */
16
+/*   Higher baud rate speeds up programming               */
17
+/*   Written almost entirely in C                         */
18
+/*   Customisable timeout with accurate timeconstant      */
19
+/*   Optional virtual UART. No hardware UART required.    */
20
+/*   Optional virtual boot partition for devices without. */
21
+/*                                                        */
22
+/* What you lose:                                         */
23
+/*   Implements a skeleton STK500 protocol which is       */
24
+/*     missing several features including EEPROM          */
25
+/*     programming and non-page-aligned writes            */
26
+/*   High baud rate breaks compatibility with standard    */
27
+/*     Arduino flash settings                             */
28
+/*                                                        */
29
+/* Fully supported:                                       */
30
+/*   ATmega168 based devices  (Diecimila etc)             */
31
+/*   ATmega328P based devices (Duemilanove etc)           */
32
+/*                                                        */
33
+/* Alpha test                                             */
34
+/*   ATmega1280 based devices (Arduino Mega)              */
35
+/*                                                        */
36
+/* Work in progress:                                      */
37
+/*   ATmega644P based devices (Sanguino)                  */
38
+/*   ATtiny84 based devices (Luminet)                     */
39
+/*                                                        */
40
+/* Does not support:                                      */
41
+/*   USB based devices (eg. Teensy)                       */
42
+/*                                                        */
43
+/* Assumptions:                                           */
44
+/*   The code makes several assumptions that reduce the   */
45
+/*   code size. They are all true after a hardware reset, */
46
+/*   but may not be true if the bootloader is called by   */
47
+/*   other means or on other hardware.                    */
48
+/*     No interrupts can occur                            */
49
+/*     UART and Timer 1 are set to their reset state      */
50
+/*     SP points to RAMEND                                */
51
+/*                                                        */
52
+/* Code builds on code, libraries and optimisations from: */
53
+/*   stk500boot.c          by Jason P. Kyle               */
54
+/*   Arduino bootloader    http://arduino.cc              */
55
+/*   Spiff's 1K bootloader http://spiffie.org/know/arduino_1k_bootloader/bootloader.shtml */
56
+/*   avr-libc project      http://nongnu.org/avr-libc     */
57
+/*   Adaboot               http://www.ladyada.net/library/arduino/bootloader.html */
58
+/*   AVR305                Atmel Application Note         */
59
+/*                                                        */
60
+/* This program is free software; you can redistribute it */
61
+/* and/or modify it under the terms of the GNU General    */
62
+/* Public License as published by the Free Software       */
63
+/* Foundation; either version 2 of the License, or        */
64
+/* (at your option) any later version.                    */
65
+/*                                                        */
66
+/* This program is distributed in the hope that it will   */
67
+/* be useful, but WITHOUT ANY WARRANTY; without even the  */
68
+/* implied warranty of MERCHANTABILITY or FITNESS FOR A   */
69
+/* PARTICULAR PURPOSE.  See the GNU General Public        */
70
+/* License for more details.                              */
71
+/*                                                        */
72
+/* You should have received a copy of the GNU General     */
73
+/* Public License along with this program; if not, write  */
74
+/* to the Free Software Foundation, Inc.,                 */
75
+/* 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA */
76
+/*                                                        */
77
+/* Licence can be viewed at                               */
78
+/* http://www.fsf.org/licenses/gpl.txt                    */
79
+/*                                                        */
80
+/**********************************************************/
81
+
82
+
83
+/**********************************************************/
84
+/*                                                        */
85
+/* Optional defines:                                      */
86
+/*                                                        */
87
+/**********************************************************/
88
+/*                                                        */
89
+/* BIG_BOOT:                                              */
90
+/* Build a 1k bootloader, not 512 bytes. This turns on    */
91
+/* extra functionality.                                   */
92
+/*                                                        */
93
+/* BAUD_RATE:                                             */
94
+/* Set bootloader baud rate.                              */
95
+/*                                                        */
96
+/* LUDICROUS_SPEED:                                       */
97
+/* 230400 baud :-)                                        */
98
+/*                                                        */
99
+/* SOFT_UART:                                             */
100
+/* Use AVR305 soft-UART instead of hardware UART.         */
101
+/*                                                        */
102
+/* LED_START_FLASHES:                                     */
103
+/* Number of LED flashes on bootup.                       */
104
+/*                                                        */
105
+/* LED_DATA_FLASH:                                        */
106
+/* Flash LED when transferring data. For boards without   */
107
+/* TX or RX LEDs, or for people who like blinky lights.   */
108
+/*                                                        */
109
+/* SUPPORT_EEPROM:                                        */
110
+/* Support reading and writing from EEPROM. This is not   */
111
+/* used by Arduino, so off by default.                    */
112
+/*                                                        */
113
+/* TIMEOUT_MS:                                            */
114
+/* Bootloader timeout period, in milliseconds.            */
115
+/* 500,1000,2000,4000,8000 supported.                     */
116
+/*                                                        */
117
+/**********************************************************/
118
+
119
+/**********************************************************/
120
+/* Version Numbers!                                       */
121
+/*                                                        */
122
+/* Arduino Optiboot now includes this Version number in   */
123
+/* the source and object code.                            */
124
+/*                                                        */
125
+/* Version 3 was released as zip from the optiboot        */
126
+/*  repository and was distributed with Arduino 0022.     */
127
+/* Version 4 starts with the arduino repository commit    */
128
+/*  that brought the arduino repository up-to-date with   */
129
+/* the optiboot source tree changes since v3.             */
130
+/*                                                        */
131
+/**********************************************************/
132
+
133
+/**********************************************************/
134
+/* Edit History:                                          */
135
+/*                                                        */
136
+/* Jan 2012:                                              */
137
+/* 4.5 WestfW: fix NRWW value for m1284.                  */
138
+/* 4.4 WestfW: use attribute OS_main instead of naked for */
139
+/*             main().  This allows optimizations that we */
140
+/*             count on, which are prohibited in naked    */
141
+/*             functions due to PR42240.  (keeps us less  */
142
+/*             than 512 bytes when compiler is gcc4.5     */
143
+/*             (code from 4.3.2 remains the same.)        */
144
+/* 4.4 WestfW and Maniacbug:  Add m1284 support.  This    */
145
+/*             does not change the 328 binary, so the     */
146
+/*             version number didn't change either. (?)   */
147
+/* June 2011:                                             */
148
+/* 4.4 WestfW: remove automatic soft_uart detect (didn't  */
149
+/*             know what it was doing or why.)  Added a   */
150
+/*             check of the calculated BRG value instead. */
151
+/*             Version stays 4.4; existing binaries are   */
152
+/*             not changed.                               */
153
+/* 4.4 WestfW: add initialization of address to keep      */
154
+/*             the compiler happy.  Change SC'ed targets. */
155
+/*             Return the SW version via READ PARAM       */
156
+/* 4.3 WestfW: catch framing errors in getch(), so that   */
157
+/*             AVRISP works without HW kludges.           */
158
+/*  http://code.google.com/p/arduino/issues/detail?id=368n*/
159
+/* 4.2 WestfW: reduce code size, fix timeouts, change     */
160
+/*             verifySpace to use WDT instead of appstart */
161
+/* 4.1 WestfW: put version number in binary.              */
162
+/**********************************************************/
163
+
164
+#define OPTIBOOT_MAJVER 4
165
+#define OPTIBOOT_MINVER 5
166
+
167
+#define MAKESTR(a) #a
168
+#define MAKEVER(a, b) MAKESTR(a*256+b)
169
+
170
+asm("  .section .version\n"
171
+    "optiboot_version:  .word " MAKEVER(OPTIBOOT_MAJVER, OPTIBOOT_MINVER) "\n"
172
+    "  .section .text\n");
173
+
174
+#include <inttypes.h>
175
+#include <avr/io.h>
176
+#include <avr/pgmspace.h>
177
+
178
+// <avr/boot.h> uses sts instructions, but this version uses out instructions
179
+// This saves cycles and program memory.
180
+#include "boot.h"
181
+
182
+
183
+// We don't use <avr/wdt.h> as those routines have interrupt overhead we don't need.
184
+
185
+#include "pin_defs.h"
186
+#include "stk500.h"
187
+
188
+#ifndef LED_START_FLASHES
189
+#define LED_START_FLASHES 0
190
+#endif
191
+
192
+#ifdef LUDICROUS_SPEED
193
+#define BAUD_RATE 230400L
194
+#endif
195
+
196
+/* set the UART baud rate defaults */
197
+#ifndef BAUD_RATE
198
+#if F_CPU >= 8000000L
199
+#define BAUD_RATE   115200L // Highest rate Avrdude win32 will support
200
+#elsif F_CPU >= 1000000L
201
+#define BAUD_RATE   9600L   // 19200 also supported, but with significant error
202
+#elsif F_CPU >= 128000L
203
+#define BAUD_RATE   4800L   // Good for 128kHz internal RC
204
+#else
205
+#define BAUD_RATE 1200L     // Good even at 32768Hz
206
+#endif
207
+#endif
208
+
209
+#if 0
210
+/* Switch in soft UART for hard baud rates */
211
+/*
212
+ * I don't understand what this was supposed to accomplish, where the
213
+ * constant "280" came from, or why automatically (and perhaps unexpectedly)
214
+ * switching to a soft uart is a good thing, so I'm undoing this in favor
215
+ * of a range check using the same calc used to config the BRG...
216
+ */
217
+#if (F_CPU/BAUD_RATE) > 280 // > 57600 for 16MHz
218
+#ifndef SOFT_UART
219
+#define SOFT_UART
220
+#endif
221
+#endif
222
+#else // 0
223
+#if (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 > 250
224
+#error Unachievable baud rate (too slow) BAUD_RATE 
225
+#endif // baud rate slow check
226
+#if (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 < 3
227
+#error Unachievable baud rate (too fast) BAUD_RATE 
228
+#endif // baud rate fastn check
229
+#endif
230
+
231
+/* Watchdog settings */
232
+#define WATCHDOG_OFF    (0)
233
+#define WATCHDOG_16MS   (_BV(WDE))
234
+#define WATCHDOG_32MS   (_BV(WDP0) | _BV(WDE))
235
+#define WATCHDOG_64MS   (_BV(WDP1) | _BV(WDE))
236
+#define WATCHDOG_125MS  (_BV(WDP1) | _BV(WDP0) | _BV(WDE))
237
+#define WATCHDOG_250MS  (_BV(WDP2) | _BV(WDE))
238
+#define WATCHDOG_500MS  (_BV(WDP2) | _BV(WDP0) | _BV(WDE))
239
+#define WATCHDOG_1S     (_BV(WDP2) | _BV(WDP1) | _BV(WDE))
240
+#define WATCHDOG_2S     (_BV(WDP2) | _BV(WDP1) | _BV(WDP0) | _BV(WDE))
241
+#ifndef __AVR_ATmega8__
242
+#define WATCHDOG_4S     (_BV(WDP3) | _BV(WDE))
243
+#define WATCHDOG_8S     (_BV(WDP3) | _BV(WDP0) | _BV(WDE))
244
+#endif
245
+
246
+/* Function Prototypes */
247
+/* The main function is in init9, which removes the interrupt vector table */
248
+/* we don't need. It is also 'naked', which means the compiler does not    */
249
+/* generate any entry or exit code itself. */
250
+int main(void) __attribute__ ((OS_main)) __attribute__ ((section (".init9")));
251
+void putch(char);
252
+uint8_t getch(void);
253
+static inline void getNch(uint8_t); /* "static inline" is a compiler hint to reduce code size */
254
+void verifySpace();
255
+static inline void flash_led(uint8_t);
256
+uint8_t getLen();
257
+static inline void watchdogReset();
258
+void watchdogConfig(uint8_t x);
259
+#ifdef SOFT_UART
260
+void uartDelay() __attribute__ ((naked));
261
+#endif
262
+void appStart() __attribute__ ((naked));
263
+
264
+/*
265
+ * NRWW memory
266
+ * Addresses below NRWW (Non-Read-While-Write) can be programmed while
267
+ * continuing to run code from flash, slightly speeding up programming
268
+ * time.  Beware that Atmel data sheets specify this as a WORD address,
269
+ * while optiboot will be comparing against a 16-bit byte address.  This
270
+ * means that on a part with 128kB of memory, the upper part of the lower
271
+ * 64k will get NRWW processing as well, even though it doesn't need it.
272
+ * That's OK.  In fact, you can disable the overlapping processing for
273
+ * a part entirely by setting NRWWSTART to zero.  This reduces code
274
+ * space a bit, at the expense of being slightly slower, overall.
275
+ *
276
+ * RAMSTART should be self-explanatory.  It's bigger on parts with a
277
+ * lot of peripheral registers.
278
+ */
279
+#if defined(__AVR_ATmega168__)
280
+#define RAMSTART (0x100)
281
+#define NRWWSTART (0x3800)
282
+#elif defined(__AVR_ATmega328P__)
283
+#define RAMSTART (0x100)
284
+#define NRWWSTART (0x7000)
285
+#elif defined (__AVR_ATmega644P__)
286
+#define RAMSTART (0x100)
287
+#define NRWWSTART (0xE000)
288
+#elif defined (__AVR_ATmega1284P__)
289
+#define RAMSTART (0x100)
290
+#define NRWWSTART (0xE000)
291
+#elif defined(__AVR_ATtiny84__)
292
+#define RAMSTART (0x100)
293
+#define NRWWSTART (0x0000)
294
+#elif defined(__AVR_ATmega1280__)
295
+#define RAMSTART (0x200)
296
+#define NRWWSTART (0xE000)
297
+#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__)
298
+#define RAMSTART (0x100)
299
+#define NRWWSTART (0x1800)
300
+#endif
301
+
302
+/* C zero initialises all global variables. However, that requires */
303
+/* These definitions are NOT zero initialised, but that doesn't matter */
304
+/* This allows us to drop the zero init code, saving us memory */
305
+#define buff    ((uint8_t*)(RAMSTART))
306
+#ifdef VIRTUAL_BOOT_PARTITION
307
+#define rstVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+4))
308
+#define wdtVect (*(uint16_t*)(RAMSTART+SPM_PAGESIZE*2+6))
309
+#endif
310
+
311
+/* main program starts here */
312
+int main(void) {
313
+  uint8_t ch;
314
+
315
+  /*
316
+   * Making these local and in registers prevents the need for initializing
317
+   * them, and also saves space because code no longer stores to memory.
318
+   * (initializing address keeps the compiler happy, but isn't really
319
+   *  necessary, and uses 4 bytes of flash.)
320
+   */
321
+  register uint16_t address = 0;
322
+  register uint8_t  length;
323
+
324
+  // After the zero init loop, this is the first code to run.
325
+  //
326
+  // This code makes the following assumptions:
327
+  //  No interrupts will execute
328
+  //  SP points to RAMEND
329
+  //  r1 contains zero
330
+  //
331
+  // If not, uncomment the following instructions:
332
+  // cli();
333
+  asm volatile ("clr __zero_reg__");
334
+#ifdef __AVR_ATmega8__
335
+  SP=RAMEND;  // This is done by hardware reset
336
+#endif
337
+
338
+  // Adaboot no-wait mod
339
+  ch = MCUSR;
340
+  MCUSR = 0;
341
+  if (!(ch & _BV(EXTRF))) appStart();
342
+
343
+#if LED_START_FLASHES > 0
344
+  // Set up Timer 1 for timeout counter
345
+  TCCR1B = _BV(CS12) | _BV(CS10); // div 1024
346
+#endif
347
+#ifndef SOFT_UART
348
+#ifdef __AVR_ATmega8__
349
+  UCSRA = _BV(U2X); //Double speed mode USART
350
+  UCSRB = _BV(RXEN) | _BV(TXEN);  // enable Rx & Tx
351
+  UCSRC = _BV(URSEL) | _BV(UCSZ1) | _BV(UCSZ0);  // config USART; 8N1
352
+  UBRRL = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
353
+#else
354
+  UCSR0A = _BV(U2X0); //Double speed mode USART0
355
+  UCSR0B = _BV(RXEN0) | _BV(TXEN0);
356
+  UCSR0C = _BV(UCSZ00) | _BV(UCSZ01);
357
+  UBRR0L = (uint8_t)( (F_CPU + BAUD_RATE * 4L) / (BAUD_RATE * 8L) - 1 );
358
+#endif
359
+#endif
360
+
361
+  // Set up watchdog to trigger after 500ms
362
+  watchdogConfig(WATCHDOG_1S);
363
+
364
+  /* Set LED pin as output */
365
+  LED_DDR |= _BV(LED);
366
+
367
+#ifdef SOFT_UART
368
+  /* Set TX pin as output */
369
+  UART_DDR |= _BV(UART_TX_BIT);
370
+#endif
371
+
372
+#if LED_START_FLASHES > 0
373
+  /* Flash onboard LED to signal entering of bootloader */
374
+  flash_led(LED_START_FLASHES * 2);
375
+#endif
376
+
377
+  /* Forever loop */
378
+  for (;;) {
379
+    /* get character from UART */
380
+    ch = getch();
381
+
382
+    if(ch == STK_GET_PARAMETER) {
383
+      unsigned char which = getch();
384
+      verifySpace();
385
+      if (which == 0x82) {
386
+        /*
387
+         * Send optiboot version as "minor SW version"
388
+         */
389
+        putch(OPTIBOOT_MINVER);
390
+      } else if (which == 0x81) {
391
+          putch(OPTIBOOT_MAJVER);
392
+      } else {
393
+        /*
394
+         * GET PARAMETER returns a generic 0x03 reply for
395
+         * other parameters - enough to keep Avrdude happy
396
+         */
397
+        putch(0x03);
398
+      }
399
+    }
400
+    else if(ch == STK_SET_DEVICE) {
401
+      // SET DEVICE is ignored
402
+      getNch(20);
403
+    }
404
+    else if(ch == STK_SET_DEVICE_EXT) {
405
+      // SET DEVICE EXT is ignored
406
+      getNch(5);
407
+    }
408
+    else if(ch == STK_LOAD_ADDRESS) {
409
+      // LOAD ADDRESS
410
+      uint16_t newAddress;
411
+      newAddress = getch();
412
+      newAddress = (newAddress & 0xff) | (getch() << 8);
413
+#ifdef RAMPZ
414
+      // Transfer top bit to RAMPZ
415
+      RAMPZ = (newAddress & 0x8000) ? 1 : 0;
416
+#endif
417
+      newAddress += newAddress; // Convert from word address to byte address
418
+      address = newAddress;
419
+      verifySpace();
420
+    }
421
+    else if(ch == STK_UNIVERSAL) {
422
+      // UNIVERSAL command is ignored
423
+      getNch(4);
424
+      putch(0x00);
425
+    }
426
+    /* Write memory, length is big endian and is in bytes */
427
+    else if(ch == STK_PROG_PAGE) {
428
+      // PROGRAM PAGE - we support flash programming only, not EEPROM
429
+      uint8_t *bufPtr;
430
+      uint16_t addrPtr;
431
+
432
+      getch();                  /* getlen() */
433
+      length = getch();
434
+      getch();
435
+
436
+      // If we are in RWW section, immediately start page erase
437
+      if (address < NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
438
+
439
+      // While that is going on, read in page contents
440
+      bufPtr = buff;
441
+      do *bufPtr++ = getch();
442
+      while (--length);
443
+
444
+      // If we are in NRWW section, page erase has to be delayed until now.
445
+      // Todo: Take RAMPZ into account
446
+      if (address >= NRWWSTART) __boot_page_erase_short((uint16_t)(void*)address);
447
+
448
+      // Read command terminator, start reply
449
+      verifySpace();
450
+
451
+      // If only a partial page is to be programmed, the erase might not be complete.
452
+      // So check that here
453
+      boot_spm_busy_wait();
454
+
455
+#ifdef VIRTUAL_BOOT_PARTITION
456
+      if ((uint16_t)(void*)address == 0) {
457
+        // This is the reset vector page. We need to live-patch the code so the
458
+        // bootloader runs.
459
+        //
460
+        // Move RESET vector to WDT vector
461
+        uint16_t vect = buff[0] | (buff[1]<<8);
462
+        rstVect = vect;
463
+        wdtVect = buff[8] | (buff[9]<<8);
464
+        vect -= 4; // Instruction is a relative jump (rjmp), so recalculate.
465
+        buff[8] = vect & 0xff;
466
+        buff[9] = vect >> 8;
467
+
468
+        // Add jump to bootloader at RESET vector
469
+        buff[0] = 0x7f;
470
+        buff[1] = 0xce; // rjmp 0x1d00 instruction
471
+      }
472
+#endif
473
+
474
+      // Copy buffer into programming buffer
475
+      bufPtr = buff;
476
+      addrPtr = (uint16_t)(void*)address;
477
+      ch = SPM_PAGESIZE / 2;
478
+      do {
479
+        uint16_t a;
480
+        a = *bufPtr++;
481
+        a |= (*bufPtr++) << 8;
482
+        __boot_page_fill_short((uint16_t)(void*)addrPtr,a);
483
+        addrPtr += 2;
484
+      } while (--ch);
485
+
486
+      // Write from programming buffer
487
+      __boot_page_write_short((uint16_t)(void*)address);
488
+      boot_spm_busy_wait();
489
+
490
+#if defined(RWWSRE)
491
+      // Reenable read access to flash
492
+      boot_rww_enable();
493
+#endif
494
+
495
+    }
496
+    /* Read memory block mode, length is big endian.  */
497
+    else if(ch == STK_READ_PAGE) {
498
+      // READ PAGE - we only read flash
499
+      getch();                  /* getlen() */
500
+      length = getch();
501
+      getch();
502
+
503
+      verifySpace();
504
+#ifdef VIRTUAL_BOOT_PARTITION
505
+      do {
506
+        // Undo vector patch in bottom page so verify passes
507
+        if (address == 0)       ch=rstVect & 0xff;
508
+        else if (address == 1)  ch=rstVect >> 8;
509
+        else if (address == 8)  ch=wdtVect & 0xff;
510
+        else if (address == 9) ch=wdtVect >> 8;
511
+        else ch = pgm_read_byte_near(address);
512
+        address++;
513
+        putch(ch);
514
+      } while (--length);
515
+#else
516
+#ifdef RAMPZ
517
+// Since RAMPZ should already be set, we need to use EPLM directly.
518
+//      do putch(pgm_read_byte_near(address++));
519
+//      while (--length);
520
+      do {
521
+        uint8_t result;
522
+        __asm__ ("elpm %0,Z\n":"=r"(result):"z"(address));
523
+        putch(result);
524
+        address++;
525
+      }
526
+      while (--length);
527
+#else
528
+      do putch(pgm_read_byte_near(address++));
529
+      while (--length);
530
+#endif
531
+#endif
532
+    }
533
+
534
+    /* Get device signature bytes  */
535
+    else if(ch == STK_READ_SIGN) {
536
+      // READ SIGN - return what Avrdude wants to hear
537
+      verifySpace();
538
+      putch(SIGNATURE_0);
539
+      putch(SIGNATURE_1);
540
+      putch(SIGNATURE_2);
541
+    }
542
+    else if (ch == STK_LEAVE_PROGMODE) { /* 'Q' */
543
+      // Adaboot no-wait mod
544
+      watchdogConfig(WATCHDOG_16MS);
545
+      verifySpace();
546
+    }
547
+    else {
548
+      // This covers the response to commands like STK_ENTER_PROGMODE
549
+      verifySpace();
550
+    }
551
+    putch(STK_OK);
552
+  }
553
+}
554
+
555
+void putch(char ch) {
556
+#ifndef SOFT_UART
557
+  while (!(UCSR0A & _BV(UDRE0)));
558
+  UDR0 = ch;
559
+#else
560
+  __asm__ __volatile__ (
561
+    "   com %[ch]\n" // ones complement, carry set
562
+    "   sec\n"
563
+    "1: brcc 2f\n"
564
+    "   cbi %[uartPort],%[uartBit]\n"
565
+    "   rjmp 3f\n"
566
+    "2: sbi %[uartPort],%[uartBit]\n"
567
+    "   nop\n"
568
+    "3: rcall uartDelay\n"
569
+    "   rcall uartDelay\n"
570
+    "   lsr %[ch]\n"
571
+    "   dec %[bitcnt]\n"
572
+    "   brne 1b\n"
573
+    :
574
+    :
575
+      [bitcnt] "d" (10),
576
+      [ch] "r" (ch),
577
+      [uartPort] "I" (_SFR_IO_ADDR(UART_PORT)),
578
+      [uartBit] "I" (UART_TX_BIT)
579
+    :
580
+      "r25"
581
+  );
582
+#endif
583
+}
584
+
585
+uint8_t getch(void) {
586
+  uint8_t ch;
587
+
588
+#ifdef LED_DATA_FLASH
589
+#ifdef __AVR_ATmega8__
590
+  LED_PORT ^= _BV(LED);
591
+#else
592
+  LED_PIN |= _BV(LED);
593
+#endif
594
+#endif
595
+
596
+#ifdef SOFT_UART
597
+  __asm__ __volatile__ (
598
+    "1: sbic  %[uartPin],%[uartBit]\n"  // Wait for start edge
599
+    "   rjmp  1b\n"
600
+    "   rcall uartDelay\n"          // Get to middle of start bit
601
+    "2: rcall uartDelay\n"              // Wait 1 bit period
602
+    "   rcall uartDelay\n"              // Wait 1 bit period
603
+    "   clc\n"
604
+    "   sbic  %[uartPin],%[uartBit]\n"
605
+    "   sec\n"
606
+    "   dec   %[bitCnt]\n"
607
+    "   breq  3f\n"
608
+    "   ror   %[ch]\n"
609
+    "   rjmp  2b\n"
610
+    "3:\n"
611
+    :
612
+      [ch] "=r" (ch)
613
+    :
614
+      [bitCnt] "d" (9),
615
+      [uartPin] "I" (_SFR_IO_ADDR(UART_PIN)),
616
+      [uartBit] "I" (UART_RX_BIT)
617
+    :
618
+      "r25"
619
+);
620
+#else
621
+  while(!(UCSR0A & _BV(RXC0)))
622
+    ;
623
+  if (!(UCSR0A & _BV(FE0))) {
624
+      /*
625
+       * A Framing Error indicates (probably) that something is talking
626
+       * to us at the wrong bit rate.  Assume that this is because it
627
+       * expects to be talking to the application, and DON'T reset the
628
+       * watchdog.  This should cause the bootloader to abort and run
629
+       * the application "soon", if it keeps happening.  (Note that we
630
+       * don't care that an invalid char is returned...)
631
+       */
632
+    watchdogReset();
633
+  }
634
+  
635
+  ch = UDR0;
636
+#endif
637
+
638
+#ifdef LED_DATA_FLASH
639
+#ifdef __AVR_ATmega8__
640
+  LED_PORT ^= _BV(LED);
641
+#else
642
+  LED_PIN |= _BV(LED);
643
+#endif
644
+#endif
645
+
646
+  return ch;
647
+}
648
+
649
+#ifdef SOFT_UART
650
+// AVR305 equation: #define UART_B_VALUE (((F_CPU/BAUD_RATE)-23)/6)
651
+// Adding 3 to numerator simulates nearest rounding for more accurate baud rates
652
+#define UART_B_VALUE (((F_CPU/BAUD_RATE)-20)/6)
653
+#if UART_B_VALUE > 255
654
+#error Baud rate too slow for soft UART
655
+#endif
656
+
657
+void uartDelay() {
658
+  __asm__ __volatile__ (
659
+    "ldi r25,%[count]\n"
660
+    "1:dec r25\n"
661
+    "brne 1b\n"
662
+    "ret\n"
663
+    ::[count] "M" (UART_B_VALUE)
664
+  );
665
+}
666
+#endif
667
+
668
+void getNch(uint8_t count) {
669
+  do getch(); while (--count);
670
+  verifySpace();
671
+}
672
+
673
+void verifySpace() {
674
+  if (getch() != CRC_EOP) {
675
+    watchdogConfig(WATCHDOG_16MS);    // shorten WD timeout
676
+    while (1)                         // and busy-loop so that WD causes
677
+      ;                               //  a reset and app start.
678
+  }
679
+  putch(STK_INSYNC);
680
+}
681
+
682
+#if LED_START_FLASHES > 0
683
+void flash_led(uint8_t count) {
684
+  do {
685
+    TCNT1 = -(F_CPU/(1024*16));
686
+    TIFR1 = _BV(TOV1);
687
+    while(!(TIFR1 & _BV(TOV1)));
688
+#ifdef __AVR_ATmega8__
689
+    LED_PORT ^= _BV(LED);
690
+#else
691
+    LED_PIN |= _BV(LED);
692
+#endif
693
+    watchdogReset();
694
+  } while (--count);
695
+}
696
+#endif
697
+
698
+// Watchdog functions. These are only safe with interrupts turned off.
699
+void watchdogReset() {
700
+  __asm__ __volatile__ (
701
+    "wdr\n"
702
+  );
703
+}
704
+
705
+void watchdogConfig(uint8_t x) {
706
+  WDTCSR = _BV(WDCE) | _BV(WDE);
707
+  WDTCSR = x;
708
+}
709
+
710
+void appStart() {
711
+  watchdogConfig(WATCHDOG_OFF);
712
+  __asm__ __volatile__ (
713
+#ifdef VIRTUAL_BOOT_PARTITION
714
+    // Jump to WDT vector
715
+    "ldi r30,4\n"
716
+    "clr r31\n"
717
+#else
718
+    // Jump to RST vector
719
+    "clr r30\n"
720
+    "clr r31\n"
721
+#endif
722
+    "ijmp\n"
723
+  );
724
+}

+ 33
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega1284p/optiboot_1284P_20MHz_57k6_baud.hex ファイルの表示

@@ -0,0 +1,33 @@
1
+:020000021000EC
2
+:10FE00000F92CDB7DEB7112484B714BE81FFDFD0C7
3
+:10FE100082E08093C00088E18093C10086E08093F7
4
+:10FE2000C2008AE28093C4008EE0BBD0209A00E03A
5
+:10FE300010E0EE24E394E1E1DE2EF3E0FF2EA5D006
6
+:10FE4000813471F4A2D08983B2D08981823809F4D7
7
+:10FE50008BC0813811F484E001C083E08FD08BC067
8
+:10FE6000823411F484E103C0853419F485E0A7D00D
9
+:10FE700082C0853591F489D0A82EBB2486D0082F66
10
+:10FE800010E0102F00270A291B29812F881F88279F
11
+:10FE9000881F8BBF000F111F6DC0863521F484E0D1
12
+:10FEA0008ED080E0DBCF843609F040C06ED06DD0BC
13
+:10FEB000C82E6BD080EE0030180718F4F801F7BE9A
14
+:10FEC000E895A12C51E0B52E60D0F50181935F013A
15
+:10FED000CE16D1F7F0EE00301F0718F0F801F7BE8C
16
+:10FEE000E89565D007B600FCFDCFF801A0E0B1E0D1
17
+:10FEF0002C9130E011968C91119790E0982F8827E3
18
+:10FF0000822B932B12960C01E7BEE89511243296B2
19
+:10FF100082E0A030B80761F785E0F80187BFE89577
20
+:10FF200007B600FCFDCFD7BEE89525C08437A9F4FD
21
+:10FF30002CD02BD0B82E29D03AD0CB2C4801F401AC
22
+:10FF400086911CD00894811C911CCA94C1F70F5F44
23
+:10FF50001F4FBA940B0D111D0EC0853739F427D0F1
24
+:10FF60008EE10CD087E90AD085E078CF813511F495
25
+:10FF700088E017D01CD080E101D061CF9091C00003
26
+:10FF800095FFFCCF8093C60008958091C00087FF45
27
+:10FF9000FCCF8091C00084FD01C0A8958091C6006F
28
+:10FFA0000895E0E6F0E098E1908380830895EDDF26
29
+:10FFB000803219F088E0F5DFFFCF84E1DFCFCF9307
30
+:10FFC000C82FE3DFC150E9F7F2DFCF91089580E059
31
+:08FFD000E8DFEE27FF2709948A
32
+:040000031000FE00EB
33
+:00000001FF

+ 81
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega1284p/pin_defs.h ファイルの表示

@@ -0,0 +1,81 @@
1
+#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega88) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__)
2
+/* Onboard LED is connected to pin PB5 in Arduino NG, Diecimila, and Duemilanove */
3
+#define LED_DDR     DDRB
4
+#define LED_PORT    PORTB
5
+#define LED_PIN     PINB
6
+#define LED         PINB5
7
+
8
+/* Ports for soft UART */
9
+#ifdef SOFT_UART
10
+#define UART_PORT   PORTD
11
+#define UART_PIN    PIND
12
+#define UART_DDR    DDRD
13
+#define UART_TX_BIT 1
14
+#define UART_RX_BIT 0
15
+#endif
16
+#endif
17
+
18
+#if defined(__AVR_ATmega8__)
19
+  //Name conversion R.Wiersma
20
+  #define UCSR0A        UCSRA
21
+  #define UDR0          UDR
22
+  #define UDRE0         UDRE
23
+  #define RXC0          RXC
24
+  #define FE0           FE
25
+  #define TIFR1         TIFR
26
+  #define WDTCSR        WDTCR
27
+#endif
28
+
29
+/* Luminet support */
30
+#if defined(__AVR_ATtiny84__)
31
+/* Red LED is connected to pin PA4 */
32
+#define LED_DDR     DDRA
33
+#define LED_PORT    PORTA
34
+#define LED_PIN     PINA
35
+#define LED         PINA4
36
+/* Ports for soft UART - left port only for now. TX/RX on PA2/PA3 */
37
+#ifdef SOFT_UART
38
+#define UART_PORT   PORTA
39
+#define UART_PIN    PINA
40
+#define UART_DDR    DDRA
41
+#define UART_TX_BIT 2
42
+#define UART_RX_BIT 3
43
+#endif
44
+#endif
45
+
46
+/* Sanguino support */
47
+#if defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
48
+/* Onboard LED is connected to pin PB0 on Sanguino */
49
+#define LED_DDR     DDRB
50
+#define LED_PORT    PORTB
51
+#define LED_PIN     PINB
52
+#define LED         PINB0
53
+
54
+/* Ports for soft UART */
55
+#ifdef SOFT_UART
56
+#define UART_PORT   PORTD
57
+#define UART_PIN    PIND
58
+#define UART_DDR    DDRD
59
+#define UART_TX_BIT 1
60
+#define UART_RX_BIT 0
61
+#endif
62
+#endif
63
+
64
+/* Mega support */
65
+#if defined(__AVR_ATmega1280__)
66
+/* Onboard LED is connected to pin PB7 on Arduino Mega */
67
+#define LED_DDR     DDRB
68
+#define LED_PORT    PORTB
69
+#define LED_PIN     PINB
70
+#define LED         PINB7
71
+
72
+/* Ports for soft UART */
73
+#ifdef SOFT_UART
74
+#define UART_PORT   PORTE
75
+#define UART_PIN    PINE
76
+#define UART_DDR    DDRE
77
+#define UART_TX_BIT 1
78
+#define UART_RX_BIT 0
79
+#endif
80
+#endif
81
+

+ 39
- 0
ArduinoAddons/Arduino_0.xx/Sanguino/bootloaders/atmega1284p/stk500.h ファイルの表示

@@ -0,0 +1,39 @@
1
+/* STK500 constants list, from AVRDUDE */
2
+#define STK_OK              0x10
3
+#define STK_FAILED          0x11  // Not used
4
+#define STK_UNKNOWN         0x12  // Not used
5
+#define STK_NODEVICE        0x13  // Not used
6
+#define STK_INSYNC          0x14  // ' '
7
+#define STK_NOSYNC          0x15  // Not used
8
+#define ADC_CHANNEL_ERROR   0x16  // Not used
9
+#define ADC_MEASURE_OK      0x17  // Not used
10
+#define PWM_CHANNEL_ERROR   0x18  // Not used
11
+#define PWM_ADJUST_OK       0x19  // Not used
12
+#define CRC_EOP             0x20  // 'SPACE'
13
+#define STK_GET_SYNC        0x30  // '0'
14
+#define STK_GET_SIGN_ON     0x31  // '1'
15
+#define STK_SET_PARAMETER   0x40  // '@'
16
+#define STK_GET_PARAMETER   0x41  // 'A'
17
+#define STK_SET_DEVICE      0x42  // 'B'
18
+#define STK_SET_DEVICE_EXT  0x45  // 'E'
19
+#define STK_ENTER_PROGMODE  0x50  // 'P'
20
+#define STK_LEAVE_PROGMODE  0x51  // 'Q'
21
+#define STK_CHIP_ERASE      0x52  // 'R'
22
+#define STK_CHECK_AUTOINC   0x53  // 'S'
23
+#define STK_LOAD_ADDRESS    0x55  // 'U'
24
+#define STK_UNIVERSAL       0x56  // 'V'
25
+#define STK_PROG_FLASH      0x60  // '`'
26
+#define STK_PROG_DATA       0x61  // 'a'
27
+#define STK_PROG_FUSE       0x62  // 'b'
28
+#define STK_PROG_LOCK       0x63  // 'c'
29
+#define STK_PROG_PAGE       0x64  // 'd'
30
+#define STK_PROG_FUSE_EXT   0x65  // 'e'
31
+#define STK_READ_FLASH      0x70  // 'p'
32
+#define STK_READ_DATA       0x71  // 'q'
33
+#define STK_READ_FUSE       0x72  // 'r'
34
+#define STK_READ_LOCK       0x73  // 's'
35
+#define STK_READ_PAGE       0x74  // 't'
36
+#define STK_READ_SIGN       0x75  // 'u'
37
+#define STK_READ_OSCCAL     0x76  // 'v'
38
+#define STK_READ_FUSE_EXT   0x77  // 'w'
39
+#define STK_READ_OSCCAL_EXT 0x78  // 'x'

+ 0
- 135
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/Copy of wiring.h ファイルの表示

@@ -1,135 +0,0 @@
1
-/*
2
-  wiring.h - Partial implementation of the Wiring API for the ATmega8.
3
-  Part of Arduino - http://www.arduino.cc/
4
-
5
-  Copyright (c) 2005-2006 David A. Mellis
6
-
7
-  This library is free software; you can redistribute it and/or
8
-  modify it under the terms of the GNU Lesser General Public
9
-  License as published by the Free Software Foundation; either
10
-  version 2.1 of the License, or (at your option) any later version.
11
-
12
-  This library is distributed in the hope that it will be useful,
13
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
-  Lesser General Public License for more details.
16
-
17
-  You should have received a copy of the GNU Lesser General
18
-  Public License along with this library; if not, write to the
19
-  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20
-  Boston, MA  02111-1307  USA
21
-
22
-  $Id$
23
-*/
24
-
25
-#ifndef Wiring_h
26
-#define Wiring_h
27
-
28
-#include <avr/io.h>
29
-#include <stdlib.h>
30
-#include "binary.h"
31
-
32
-#ifdef __cplusplus
33
-extern "C"{
34
-#endif
35
-
36
-#define HIGH 0x1
37
-#define LOW  0x0
38
-
39
-#define INPUT 0x0
40
-#define OUTPUT 0x1
41
-
42
-#define true 0x1
43
-#define false 0x0
44
-
45
-#define PI 3.1415926535897932384626433832795
46
-#define HALF_PI 1.5707963267948966192313216916398
47
-#define TWO_PI 6.283185307179586476925286766559
48
-#define DEG_TO_RAD 0.017453292519943295769236907684886
49
-#define RAD_TO_DEG 57.295779513082320876798154814105
50
-
51
-#define SERIAL  0x0
52
-#define DISPLAY 0x1
53
-
54
-#define LSBFIRST 0
55
-#define MSBFIRST 1
56
-
57
-#define CHANGE 1
58
-#define FALLING 2
59
-#define RISING 3
60
-
61
-#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
62
-#define INTERNAL1V1 2
63
-#define INTERNAL2V56 3
64
-#else
65
-#define INTERNAL 3
66
-#endif
67
-#define DEFAULT 1
68
-#define EXTERNAL 0
69
-
70
-// undefine stdlib's abs if encountered
71
-#ifdef abs
72
-#undef abs
73
-#endif
74
-
75
-#define min(a,b) ((a)<(b)?(a):(b))
76
-#define max(a,b) ((a)>(b)?(a):(b))
77
-#define abs(x) ((x)>0?(x):-(x))
78
-#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
79
-#define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
80
-#define radians(deg) ((deg)*DEG_TO_RAD)
81
-#define degrees(rad) ((rad)*RAD_TO_DEG)
82
-#define sq(x) ((x)*(x))
83
-
84
-#define interrupts() sei()
85
-#define noInterrupts() cli()
86
-
87
-#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
88
-#define clockCyclesToMicroseconds(a) ( ((a) * 1000L) / (F_CPU / 1000L) )
89
-#define microsecondsToClockCycles(a) ( ((a) * (F_CPU / 1000L)) / 1000L )
90
-
91
-#define lowByte(w) ((uint8_t) ((w) & 0xff))
92
-#define highByte(w) ((uint8_t) ((w) >> 8))
93
-
94
-#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
95
-#define bitSet(value, bit) ((value) |= (1UL << (bit)))
96
-#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
97
-#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
98
-
99
-
100
-typedef unsigned int word;
101
-
102
-#define bit(b) (1UL << (b))
103
-
104
-typedef uint8_t boolean;
105
-typedef uint8_t byte;
106
-
107
-void init(void);
108
-
109
-void pinMode(uint8_t, uint8_t);
110
-void digitalWrite(uint8_t, uint8_t);
111
-int digitalRead(uint8_t);
112
-int analogRead(uint8_t);
113
-void analogReference(uint8_t mode);
114
-void analogWrite(uint8_t, int);
115
-
116
-unsigned long millis(void);
117
-unsigned long micros(void);
118
-void delay(unsigned long);
119
-void delayMicroseconds(unsigned int us);
120
-unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);
121
-
122
-void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
123
-uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
124
-
125
-void attachInterrupt(uint8_t, void (*)(void), int mode);
126
-void detachInterrupt(uint8_t);
127
-
128
-void setup(void);
129
-void loop(void);
130
-
131
-#ifdef __cplusplus
132
-} // extern "C"
133
-#endif
134
-
135
-#endif

+ 129
- 13
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/HardwareSerial.cpp ファイルの表示

@@ -37,7 +37,11 @@
37 37
 // using a ring buffer (I think), in which rx_buffer_head is the index of the
38 38
 // location to which to write the next incoming character and rx_buffer_tail
39 39
 // is the index of the location from which to read.
40
-#define RX_BUFFER_SIZE 128
40
+#if (RAMEND < 1000)
41
+  #define RX_BUFFER_SIZE 32
42
+#else
43
+  #define RX_BUFFER_SIZE 128
44
+#endif
41 45
 
42 46
 struct ring_buffer
43 47
 {
@@ -46,11 +50,22 @@ struct ring_buffer
46 50
   int tail;
47 51
 };
48 52
 
49
-ring_buffer rx_buffer  =  { { 0 }, 0, 0 };
53
+#if defined(UBRRH) || defined(UBRR0H)
54
+  ring_buffer rx_buffer  =  { { 0 }, 0, 0 };
55
+#endif
56
+#if defined(UBRR1H)
57
+  ring_buffer rx_buffer1  =  { { 0 }, 0, 0 };
58
+#endif
59
+#if defined(UBRR2H)
60
+  ring_buffer rx_buffer2  =  { { 0 }, 0, 0 };
61
+#endif
62
+#if defined(UBRR3H)
63
+  ring_buffer rx_buffer3  =  { { 0 }, 0, 0 };
64
+#endif
50 65
 
51 66
 inline void store_char(unsigned char c, ring_buffer *rx_buffer)
52 67
 {
53
-  int i = (unsigned int)(rx_buffer->head + 1) & (RX_BUFFER_SIZE -1);
68
+  int i = (unsigned int)(rx_buffer->head + 1) % RX_BUFFER_SIZE;
54 69
 
55 70
   // if we should be storing the received character into the location
56 71
   // just before the tail (meaning that the head would advance to the
@@ -62,13 +77,95 @@ inline void store_char(unsigned char c, ring_buffer *rx_buffer)
62 77
   }
63 78
 }
64 79
 
65
-// fixed by Mark Sproul this is on the 644/644p
66
-//SIGNAL(SIG_USART_RECV)
67
-SIGNAL(USART0_RX_vect)
68
-{
69
-  unsigned char c  =  UDR0;
70
-  store_char(c, &rx_buffer);
71
-}
80
+#if defined(USART_RX_vect)
81
+  SIGNAL(USART_RX_vect)
82
+  {
83
+  #if defined(UDR0)
84
+    unsigned char c  =  UDR0;
85
+  #elif defined(UDR)
86
+    unsigned char c  =  UDR;  //  atmega8535
87
+  #else
88
+    #error UDR not defined
89
+  #endif
90
+    store_char(c, &rx_buffer);
91
+  }
92
+#elif defined(SIG_USART0_RECV) && defined(UDR0)
93
+  SIGNAL(SIG_USART0_RECV)
94
+  {
95
+    unsigned char c  =  UDR0;
96
+    store_char(c, &rx_buffer);
97
+  }
98
+#elif defined(SIG_UART0_RECV) && defined(UDR0)
99
+  SIGNAL(SIG_UART0_RECV)
100
+  {
101
+    unsigned char c  =  UDR0;
102
+    store_char(c, &rx_buffer);
103
+  }
104
+//#elif defined(SIG_USART_RECV)
105
+#elif defined(USART0_RX_vect)
106
+  // fixed by Mark Sproul this is on the 644/644p
107
+  //SIGNAL(SIG_USART_RECV)
108
+  SIGNAL(USART0_RX_vect)
109
+  {
110
+  #if defined(UDR0)
111
+    unsigned char c  =  UDR0;
112
+  #elif defined(UDR)
113
+    unsigned char c  =  UDR;  //  atmega8, atmega32
114
+  #else
115
+    #error UDR not defined
116
+  #endif
117
+    store_char(c, &rx_buffer);
118
+  }
119
+#elif defined(SIG_UART_RECV)
120
+  // this is for atmega8
121
+  SIGNAL(SIG_UART_RECV)
122
+  {
123
+  #if defined(UDR0)
124
+    unsigned char c  =  UDR0;  //  atmega645
125
+  #elif defined(UDR)
126
+    unsigned char c  =  UDR;  //  atmega8
127
+  #endif
128
+    store_char(c, &rx_buffer);
129
+  }
130
+#elif defined(USBCON)
131
+  #warning No interrupt handler for usart 0
132
+  #warning Serial(0) is on USB interface
133
+#else
134
+  #error No interrupt handler for usart 0
135
+#endif
136
+
137
+//#if defined(SIG_USART1_RECV)
138
+#if defined(USART1_RX_vect)
139
+  //SIGNAL(SIG_USART1_RECV)
140
+  SIGNAL(USART1_RX_vect)
141
+  {
142
+    unsigned char c = UDR1;
143
+    store_char(c, &rx_buffer1);
144
+  }
145
+#elif defined(SIG_USART1_RECV)
146
+  #error SIG_USART1_RECV
147
+#endif
148
+
149
+#if defined(USART2_RX_vect) && defined(UDR2)
150
+  SIGNAL(USART2_RX_vect)
151
+  {
152
+    unsigned char c = UDR2;
153
+    store_char(c, &rx_buffer2);
154
+  }
155
+#elif defined(SIG_USART2_RECV)
156
+  #error SIG_USART2_RECV
157
+#endif
158
+
159
+#if defined(USART3_RX_vect) && defined(UDR3)
160
+  SIGNAL(USART3_RX_vect)
161
+  {
162
+    unsigned char c = UDR3;
163
+    store_char(c, &rx_buffer3);
164
+  }
165
+#elif defined(SIG_USART3_RECV)
166
+  #error SIG_USART3_RECV
167
+#endif
168
+
72 169
 
73 170
 
74 171
 // Constructors ////////////////////////////////////////////////////////////////
@@ -134,7 +231,7 @@ void HardwareSerial::end()
134 231
 
135 232
 int HardwareSerial::available(void)
136 233
 {
137
-  return (unsigned int)(RX_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) & (RX_BUFFER_SIZE-1);
234
+  return (unsigned int)(RX_BUFFER_SIZE + _rx_buffer->head - _rx_buffer->tail) % RX_BUFFER_SIZE;
138 235
 }
139 236
 
140 237
 int HardwareSerial::peek(void)
@@ -153,7 +250,7 @@ int HardwareSerial::read(void)
153 250
     return -1;
154 251
   } else {
155 252
     unsigned char c = _rx_buffer->buffer[_rx_buffer->tail];
156
-    _rx_buffer->tail = (unsigned int)(_rx_buffer->tail + 1) & (RX_BUFFER_SIZE-1);
253
+    _rx_buffer->tail = (unsigned int)(_rx_buffer->tail + 1) % RX_BUFFER_SIZE;
157 254
     return c;
158 255
   }
159 256
 }
@@ -181,7 +278,26 @@ void HardwareSerial::write(uint8_t c)
181 278
 }
182 279
 
183 280
 // Preinstantiate Objects //////////////////////////////////////////////////////
184
-HardwareSerial Serial(&rx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRE0, U2X0);
281
+
282
+#if defined(UBRRH) && defined(UBRRL)
283
+  HardwareSerial Serial(&rx_buffer, &UBRRH, &UBRRL, &UCSRA, &UCSRB, &UDR, RXEN, TXEN, RXCIE, UDRE, U2X);
284
+#elif defined(UBRR0H) && defined(UBRR0L)
285
+  HardwareSerial Serial(&rx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRE0, U2X0);
286
+#elif defined(USBCON)
287
+  #warning no serial port defined  (port 0)
288
+#else
289
+  #error no serial port defined  (port 0)
290
+#endif
291
+
292
+#if defined(UBRR1H)
293
+  HardwareSerial Serial1(&rx_buffer1, &UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UDR1, RXEN1, TXEN1, RXCIE1, UDRE1, U2X1);
294
+#endif
295
+#if defined(UBRR2H)
296
+  HardwareSerial Serial2(&rx_buffer2, &UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UDR2, RXEN2, TXEN2, RXCIE2, UDRE2, U2X2);
297
+#endif
298
+#if defined(UBRR3H)
299
+  HardwareSerial Serial3(&rx_buffer3, &UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UDR3, RXEN3, TXEN3, RXCIE3, UDRE3, U2X3);
300
+#endif
185 301
 
186 302
 #endif // whole file
187 303
 

+ 42
- 11
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/WInterrupts.c ファイルの表示

@@ -46,7 +46,6 @@ void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) {
46 46
     // the mode into place.
47 47
       
48 48
     // Enable the interrupt.
49
-      
50 49
     switch (interruptNum) {
51 50
 #if defined(EICRA) && defined(EICRB) && defined(EIMSK)
52 51
     case 2:
@@ -81,6 +80,19 @@ void attachInterrupt(uint8_t interruptNum, void (*userFunc)(void), int mode) {
81 80
       EICRB = (EICRB & ~((1 << ISC70) | (1 << ISC71))) | (mode << ISC70);
82 81
       EIMSK |= (1 << INT7);
83 82
       break;
83
+#elif defined(EICRA) && defined(EIMSK)
84
+    case 0:
85
+      EICRA = (EICRA & ~((1 << ISC00) | (1 << ISC01))) | (mode << ISC00);
86
+      EIMSK |= (1 << INT0);
87
+      break;
88
+    case 1:
89
+      EICRA = (EICRA & ~((1 << ISC10) | (1 << ISC11))) | (mode << ISC10);
90
+      EIMSK |= (1 << INT1);
91
+      break;
92
+    case 2:
93
+      EICRA = (EICRA & ~((1 << ISC20) | (1 << ISC21))) | (mode << ISC20);
94
+      EIMSK |= (1 << INT2);
95
+      break;
84 96
 #else
85 97
     case 0:
86 98
     #if defined(EICRA) && defined(ISC00) && defined(EIMSK)
@@ -123,15 +135,6 @@ void detachInterrupt(uint8_t interruptNum) {
123 135
     // ATmega8.  There, INT0 is 6 and INT1 is 7.)
124 136
     switch (interruptNum) {
125 137
 #if defined(EICRA) && defined(EICRB) && defined(EIMSK)
126
-    case 2:
127
-      EIMSK &= ~(1 << INT0);
128
-      break;
129
-    case 3:
130
-      EIMSK &= ~(1 << INT1);
131
-      break;
132
-    case 4:
133
-      EIMSK &= ~(1 << INT2);
134
-      break;
135 138
     case 5:
136 139
       EIMSK &= ~(1 << INT3);
137 140
       break;
@@ -147,6 +150,17 @@ void detachInterrupt(uint8_t interruptNum) {
147 150
     case 7:
148 151
       EIMSK &= ~(1 << INT7);
149 152
       break;
153
+#elif defined(EICRA) && defined(EIMSK)
154
+    case 0:
155
+      EIMSK &= ~(1 << INT0);
156
+      break;
157
+    case 1:
158
+      EIMSK &= ~(1 << INT1);
159
+      break;
160
+    case 2:
161
+      EIMSK &= ~(1 << INT2);
162
+      break;
163
+
150 164
 #else
151 165
     case 0:
152 166
     #if defined(EIMSK) && defined(INT0)
@@ -184,8 +198,8 @@ void attachInterruptTwi(void (*userFunc)(void) ) {
184 198
 }
185 199
 */
186 200
 
187
-#if defined(EICRA) && defined(EICRB)
188 201
 
202
+#if defined(EICRA) && defined(EICRB)
189 203
 SIGNAL(INT0_vect) {
190 204
   if(intFunc[EXTERNAL_INT_2])
191 205
     intFunc[EXTERNAL_INT_2]();
@@ -226,6 +240,23 @@ SIGNAL(INT7_vect) {
226 240
     intFunc[EXTERNAL_INT_7]();
227 241
 }
228 242
 
243
+#elif defined(EICRA)
244
+
245
+SIGNAL(INT0_vect) {
246
+  if(intFunc[EXTERNAL_INT_0])
247
+    intFunc[EXTERNAL_INT_0]();
248
+}
249
+
250
+SIGNAL(INT1_vect) {
251
+  if(intFunc[EXTERNAL_INT_1])
252
+    intFunc[EXTERNAL_INT_1]();
253
+}
254
+
255
+SIGNAL(INT2_vect) {
256
+  if(intFunc[EXTERNAL_INT_2])
257
+    intFunc[EXTERNAL_INT_2]();
258
+}
259
+
229 260
 #else
230 261
 
231 262
 SIGNAL(INT0_vect) {

+ 520
- 93
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/pins_arduino.c ファイルの表示

@@ -19,17 +19,54 @@
19 19
   Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20 20
   Boston, MA  02111-1307  USA
21 21
 
22
-  $Id: pins_arduino.c 254 2007-04-20 23:17:38Z mellis $
22
+  Changelog
23
+  -----------
24
+  11/25/11  - ryan@ryanmsutton.com - Add pins for Sanguino 644P and 1284P
25
+  $Id$
23 26
 */
24 27
 
25 28
 #include <avr/io.h>
26 29
 #include "wiring_private.h"
27 30
 #include "pins_arduino.h"
28 31
 
29
-// On the Sanguino board, digital pins are also used
32
+// On the Arduino board, digital pins are also used
30 33
 // for the analog output (software PWM).  Analog input
31 34
 // pins are a separate set.
32 35
 
36
+// ATMEL ATMEGA8 & 168 / ARDUINO
37
+//
38
+//                  +-\/-+
39
+//            PC6  1|    |28  PC5 (AI 5)
40
+//      (D 0) PD0  2|    |27  PC4 (AI 4)
41
+//      (D 1) PD1  3|    |26  PC3 (AI 3)
42
+//      (D 2) PD2  4|    |25  PC2 (AI 2)
43
+// PWM+ (D 3) PD3  5|    |24  PC1 (AI 1)
44
+//      (D 4) PD4  6|    |23  PC0 (AI 0)
45
+//            VCC  7|    |22  GND
46
+//            GND  8|    |21  AREF
47
+//            PB6  9|    |20  AVCC
48
+//            PB7 10|    |19  PB5 (D 13)
49
+// PWM+ (D 5) PD5 11|    |18  PB4 (D 12)
50
+// PWM+ (D 6) PD6 12|    |17  PB3 (D 11) PWM
51
+//      (D 7) PD7 13|    |16  PB2 (D 10) PWM
52
+//      (D 8) PB0 14|    |15  PB1 (D 9) PWM
53
+//                  +----+
54
+//
55
+// (PWM+ indicates the additional PWM pins on the ATmega168.)
56
+
57
+// ATMEL ATMEGA1280 / ARDUINO
58
+//
59
+// 0-7 PE0-PE7   works
60
+// 8-13 PB0-PB5  works
61
+// 14-21 PA0-PA7 works 
62
+// 22-29 PH0-PH7 works
63
+// 30-35 PG5-PG0 works
64
+// 36-43 PC7-PC0 works
65
+// 44-51 PJ7-PJ0 works
66
+// 52-59 PL7-PL0 works
67
+// 60-67 PD7-PD0 works
68
+// A0-A7 PF0-PF7
69
+// A8-A15 PK0-PK7
33 70
 // ATMEL ATMEGA644P / SANGUINO
34 71
 //
35 72
 //                   +---\/---+
@@ -55,53 +92,457 @@
55 92
 //  PWM (D 14) PD6 20|        |21  PD7 (D 15) PWM
56 93
 //                   +--------+
57 94
 //
58
-
59 95
 #define PA 1
60 96
 #define PB 2
61 97
 #define PC 3
62 98
 #define PD 4
99
+#define PE 5
100
+#define PF 6
101
+#define PG 7
102
+#define PH 8
103
+#define PJ 10
104
+#define PK 11
105
+#define PL 12
106
+
107
+
108
+#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
109
+const uint16_t PROGMEM port_to_mode_PGM[] = {
110
+	NOT_A_PORT,
111
+	&DDRA,
112
+	&DDRB,
113
+	&DDRC,
114
+	&DDRD,
115
+	&DDRE,
116
+	&DDRF,
117
+	&DDRG,
118
+	&DDRH,
119
+	NOT_A_PORT,
120
+	&DDRJ,
121
+	&DDRK,
122
+	&DDRL,
123
+};
63 124
 
125
+const uint16_t PROGMEM port_to_output_PGM[] = {
126
+	NOT_A_PORT,
127
+	&PORTA,
128
+	&PORTB,
129
+	&PORTC,
130
+	&PORTD,
131
+	&PORTE,
132
+	&PORTF,
133
+	&PORTG,
134
+	&PORTH,
135
+	NOT_A_PORT,
136
+	&PORTJ,
137
+	&PORTK,
138
+	&PORTL,
139
+};
140
+
141
+const uint16_t PROGMEM port_to_input_PGM[] = {
142
+	NOT_A_PIN,
143
+	&PINA,
144
+	&PINB,
145
+	&PINC,
146
+	&PIND,
147
+	&PINE,
148
+	&PINF,
149
+	&PING,
150
+	&PINH,
151
+	NOT_A_PIN,
152
+	&PINJ,
153
+	&PINK,
154
+	&PINL,
155
+};
156
+
157
+const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
158
+	// PORTLIST		
159
+	// -------------------------------------------		
160
+	PE	, // PE 0 ** 0 ** USART0_RX	
161
+	PE	, // PE 1 ** 1 ** USART0_TX	
162
+	PE	, // PE 4 ** 2 ** PWM2	
163
+	PE	, // PE 5 ** 3 ** PWM3	
164
+	PG	, // PG 5 ** 4 ** PWM4	
165
+	PE	, // PE 3 ** 5 ** PWM5	
166
+	PH	, // PH 3 ** 6 ** PWM6	
167
+	PH	, // PH 4 ** 7 ** PWM7	
168
+	PH	, // PH 5 ** 8 ** PWM8	
169
+	PH	, // PH 6 ** 9 ** PWM9	
170
+	PB	, // PB 4 ** 10 ** PWM10	
171
+	PB	, // PB 5 ** 11 ** PWM11	
172
+	PB	, // PB 6 ** 12 ** PWM12	
173
+	PB	, // PB 7 ** 13 ** PWM13	
174
+	PJ	, // PJ 1 ** 14 ** USART3_TX	
175
+	PJ	, // PJ 0 ** 15 ** USART3_RX	
176
+	PH	, // PH 1 ** 16 ** USART2_TX	
177
+	PH	, // PH 0 ** 17 ** USART2_RX	
178
+	PD	, // PD 3 ** 18 ** USART1_TX	
179
+	PD	, // PD 2 ** 19 ** USART1_RX	
180
+	PD	, // PD 1 ** 20 ** I2C_SDA	
181
+	PD	, // PD 0 ** 21 ** I2C_SCL	
182
+	PA	, // PA 0 ** 22 ** D22	
183
+	PA	, // PA 1 ** 23 ** D23	
184
+	PA	, // PA 2 ** 24 ** D24	
185
+	PA	, // PA 3 ** 25 ** D25	
186
+	PA	, // PA 4 ** 26 ** D26	
187
+	PA	, // PA 5 ** 27 ** D27	
188
+	PA	, // PA 6 ** 28 ** D28	
189
+	PA	, // PA 7 ** 29 ** D29	
190
+	PC	, // PC 7 ** 30 ** D30	
191
+	PC	, // PC 6 ** 31 ** D31	
192
+	PC	, // PC 5 ** 32 ** D32	
193
+	PC	, // PC 4 ** 33 ** D33	
194
+	PC	, // PC 3 ** 34 ** D34	
195
+	PC	, // PC 2 ** 35 ** D35	
196
+	PC	, // PC 1 ** 36 ** D36	
197
+	PC	, // PC 0 ** 37 ** D37	
198
+	PD	, // PD 7 ** 38 ** D38	
199
+	PG	, // PG 2 ** 39 ** D39	
200
+	PG	, // PG 1 ** 40 ** D40	
201
+	PG	, // PG 0 ** 41 ** D41	
202
+	PL	, // PL 7 ** 42 ** D42	
203
+	PL	, // PL 6 ** 43 ** D43	
204
+	PL	, // PL 5 ** 44 ** D44	
205
+	PL	, // PL 4 ** 45 ** D45	
206
+	PL	, // PL 3 ** 46 ** D46	
207
+	PL	, // PL 2 ** 47 ** D47	
208
+	PL	, // PL 1 ** 48 ** D48	
209
+	PL	, // PL 0 ** 49 ** D49	
210
+	PB	, // PB 3 ** 50 ** SPI_MISO	
211
+	PB	, // PB 2 ** 51 ** SPI_MOSI	
212
+	PB	, // PB 1 ** 52 ** SPI_SCK	
213
+	PB	, // PB 0 ** 53 ** SPI_SS	
214
+	PF	, // PF 0 ** 54 ** A0	
215
+	PF	, // PF 1 ** 55 ** A1	
216
+	PF	, // PF 2 ** 56 ** A2	
217
+	PF	, // PF 3 ** 57 ** A3	
218
+	PF	, // PF 4 ** 58 ** A4	
219
+	PF	, // PF 5 ** 59 ** A5	
220
+	PF	, // PF 6 ** 60 ** A6	
221
+	PF	, // PF 7 ** 61 ** A7	
222
+	PK	, // PK 0 ** 62 ** A8	
223
+	PK	, // PK 1 ** 63 ** A9	
224
+	PK	, // PK 2 ** 64 ** A10	
225
+	PK	, // PK 3 ** 65 ** A11	
226
+	PK	, // PK 4 ** 66 ** A12	
227
+	PK	, // PK 5 ** 67 ** A13	
228
+	PK	, // PK 6 ** 68 ** A14	
229
+	PK	, // PK 7 ** 69 ** A15	
230
+};
231
+
232
+const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
233
+	// PIN IN PORT		
234
+	// -------------------------------------------		
235
+	_BV( 0 )	, // PE 0 ** 0 ** USART0_RX	
236
+	_BV( 1 )	, // PE 1 ** 1 ** USART0_TX	
237
+	_BV( 4 )	, // PE 4 ** 2 ** PWM2	
238
+	_BV( 5 )	, // PE 5 ** 3 ** PWM3	
239
+	_BV( 5 )	, // PG 5 ** 4 ** PWM4	
240
+	_BV( 3 )	, // PE 3 ** 5 ** PWM5	
241
+	_BV( 3 )	, // PH 3 ** 6 ** PWM6	
242
+	_BV( 4 )	, // PH 4 ** 7 ** PWM7	
243
+	_BV( 5 )	, // PH 5 ** 8 ** PWM8	
244
+	_BV( 6 )	, // PH 6 ** 9 ** PWM9	
245
+	_BV( 4 )	, // PB 4 ** 10 ** PWM10	
246
+	_BV( 5 )	, // PB 5 ** 11 ** PWM11	
247
+	_BV( 6 )	, // PB 6 ** 12 ** PWM12	
248
+	_BV( 7 )	, // PB 7 ** 13 ** PWM13	
249
+	_BV( 1 )	, // PJ 1 ** 14 ** USART3_TX	
250
+	_BV( 0 )	, // PJ 0 ** 15 ** USART3_RX	
251
+	_BV( 1 )	, // PH 1 ** 16 ** USART2_TX	
252
+	_BV( 0 )	, // PH 0 ** 17 ** USART2_RX	
253
+	_BV( 3 )	, // PD 3 ** 18 ** USART1_TX	
254
+	_BV( 2 )	, // PD 2 ** 19 ** USART1_RX	
255
+	_BV( 1 )	, // PD 1 ** 20 ** I2C_SDA	
256
+	_BV( 0 )	, // PD 0 ** 21 ** I2C_SCL	
257
+	_BV( 0 )	, // PA 0 ** 22 ** D22	
258
+	_BV( 1 )	, // PA 1 ** 23 ** D23	
259
+	_BV( 2 )	, // PA 2 ** 24 ** D24	
260
+	_BV( 3 )	, // PA 3 ** 25 ** D25	
261
+	_BV( 4 )	, // PA 4 ** 26 ** D26	
262
+	_BV( 5 )	, // PA 5 ** 27 ** D27	
263
+	_BV( 6 )	, // PA 6 ** 28 ** D28	
264
+	_BV( 7 )	, // PA 7 ** 29 ** D29	
265
+	_BV( 7 )	, // PC 7 ** 30 ** D30	
266
+	_BV( 6 )	, // PC 6 ** 31 ** D31	
267
+	_BV( 5 )	, // PC 5 ** 32 ** D32	
268
+	_BV( 4 )	, // PC 4 ** 33 ** D33	
269
+	_BV( 3 )	, // PC 3 ** 34 ** D34	
270
+	_BV( 2 )	, // PC 2 ** 35 ** D35	
271
+	_BV( 1 )	, // PC 1 ** 36 ** D36	
272
+	_BV( 0 )	, // PC 0 ** 37 ** D37	
273
+	_BV( 7 )	, // PD 7 ** 38 ** D38	
274
+	_BV( 2 )	, // PG 2 ** 39 ** D39	
275
+	_BV( 1 )	, // PG 1 ** 40 ** D40	
276
+	_BV( 0 )	, // PG 0 ** 41 ** D41	
277
+	_BV( 7 )	, // PL 7 ** 42 ** D42	
278
+	_BV( 6 )	, // PL 6 ** 43 ** D43	
279
+	_BV( 5 )	, // PL 5 ** 44 ** D44	
280
+	_BV( 4 )	, // PL 4 ** 45 ** D45	
281
+	_BV( 3 )	, // PL 3 ** 46 ** D46	
282
+	_BV( 2 )	, // PL 2 ** 47 ** D47	
283
+	_BV( 1 )	, // PL 1 ** 48 ** D48	
284
+	_BV( 0 )	, // PL 0 ** 49 ** D49	
285
+	_BV( 3 )	, // PB 3 ** 50 ** SPI_MISO	
286
+	_BV( 2 )	, // PB 2 ** 51 ** SPI_MOSI	
287
+	_BV( 1 )	, // PB 1 ** 52 ** SPI_SCK	
288
+	_BV( 0 )	, // PB 0 ** 53 ** SPI_SS	
289
+	_BV( 0 )	, // PF 0 ** 54 ** A0	
290
+	_BV( 1 )	, // PF 1 ** 55 ** A1	
291
+	_BV( 2 )	, // PF 2 ** 56 ** A2	
292
+	_BV( 3 )	, // PF 3 ** 57 ** A3	
293
+	_BV( 4 )	, // PF 4 ** 58 ** A4	
294
+	_BV( 5 )	, // PF 5 ** 59 ** A5	
295
+	_BV( 6 )	, // PF 6 ** 60 ** A6	
296
+	_BV( 7 )	, // PF 7 ** 61 ** A7	
297
+	_BV( 0 )	, // PK 0 ** 62 ** A8	
298
+	_BV( 1 )	, // PK 1 ** 63 ** A9	
299
+	_BV( 2 )	, // PK 2 ** 64 ** A10	
300
+	_BV( 3 )	, // PK 3 ** 65 ** A11	
301
+	_BV( 4 )	, // PK 4 ** 66 ** A12	
302
+	_BV( 5 )	, // PK 5 ** 67 ** A13	
303
+	_BV( 6 )	, // PK 6 ** 68 ** A14	
304
+	_BV( 7 )	, // PK 7 ** 69 ** A15	
305
+};
306
+
307
+const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
308
+	// TIMERS		
309
+	// -------------------------------------------		
310
+	NOT_ON_TIMER	, // PE 0 ** 0 ** USART0_RX	
311
+	NOT_ON_TIMER	, // PE 1 ** 1 ** USART0_TX	
312
+	TIMER3B	, // PE 4 ** 2 ** PWM2	
313
+	TIMER3C	, // PE 5 ** 3 ** PWM3	
314
+	TIMER0B	, // PG 5 ** 4 ** PWM4	
315
+	TIMER3A	, // PE 3 ** 5 ** PWM5	
316
+	TIMER4A	, // PH 3 ** 6 ** PWM6	
317
+	TIMER4B	, // PH 4 ** 7 ** PWM7	
318
+	TIMER4C	, // PH 5 ** 8 ** PWM8	
319
+	TIMER2B	, // PH 6 ** 9 ** PWM9	
320
+	TIMER2A	, // PB 4 ** 10 ** PWM10	
321
+	TIMER1A	, // PB 5 ** 11 ** PWM11	
322
+	TIMER1B	, // PB 6 ** 12 ** PWM12	
323
+	TIMER0A	, // PB 7 ** 13 ** PWM13	
324
+	NOT_ON_TIMER	, // PJ 1 ** 14 ** USART3_TX	
325
+	NOT_ON_TIMER	, // PJ 0 ** 15 ** USART3_RX	
326
+	NOT_ON_TIMER	, // PH 1 ** 16 ** USART2_TX	
327
+	NOT_ON_TIMER	, // PH 0 ** 17 ** USART2_RX	
328
+	NOT_ON_TIMER	, // PD 3 ** 18 ** USART1_TX	
329
+	NOT_ON_TIMER	, // PD 2 ** 19 ** USART1_RX	
330
+	NOT_ON_TIMER	, // PD 1 ** 20 ** I2C_SDA	
331
+	NOT_ON_TIMER	, // PD 0 ** 21 ** I2C_SCL	
332
+	NOT_ON_TIMER	, // PA 0 ** 22 ** D22	
333
+	NOT_ON_TIMER	, // PA 1 ** 23 ** D23	
334
+	NOT_ON_TIMER	, // PA 2 ** 24 ** D24	
335
+	NOT_ON_TIMER	, // PA 3 ** 25 ** D25	
336
+	NOT_ON_TIMER	, // PA 4 ** 26 ** D26	
337
+	NOT_ON_TIMER	, // PA 5 ** 27 ** D27	
338
+	NOT_ON_TIMER	, // PA 6 ** 28 ** D28	
339
+	NOT_ON_TIMER	, // PA 7 ** 29 ** D29	
340
+	NOT_ON_TIMER	, // PC 7 ** 30 ** D30	
341
+	NOT_ON_TIMER	, // PC 6 ** 31 ** D31	
342
+	NOT_ON_TIMER	, // PC 5 ** 32 ** D32	
343
+	NOT_ON_TIMER	, // PC 4 ** 33 ** D33	
344
+	NOT_ON_TIMER	, // PC 3 ** 34 ** D34	
345
+	NOT_ON_TIMER	, // PC 2 ** 35 ** D35	
346
+	NOT_ON_TIMER	, // PC 1 ** 36 ** D36	
347
+	NOT_ON_TIMER	, // PC 0 ** 37 ** D37	
348
+	NOT_ON_TIMER	, // PD 7 ** 38 ** D38	
349
+	NOT_ON_TIMER	, // PG 2 ** 39 ** D39	
350
+	NOT_ON_TIMER	, // PG 1 ** 40 ** D40	
351
+	NOT_ON_TIMER	, // PG 0 ** 41 ** D41	
352
+	NOT_ON_TIMER	, // PL 7 ** 42 ** D42	
353
+	NOT_ON_TIMER	, // PL 6 ** 43 ** D43	
354
+	TIMER5C	, // PL 5 ** 44 ** D44	
355
+	TIMER5B	, // PL 4 ** 45 ** D45	
356
+	TIMER5A	, // PL 3 ** 46 ** D46	
357
+	NOT_ON_TIMER	, // PL 2 ** 47 ** D47	
358
+	NOT_ON_TIMER	, // PL 1 ** 48 ** D48	
359
+	NOT_ON_TIMER	, // PL 0 ** 49 ** D49	
360
+	NOT_ON_TIMER	, // PB 3 ** 50 ** SPI_MISO	
361
+	NOT_ON_TIMER	, // PB 2 ** 51 ** SPI_MOSI	
362
+	NOT_ON_TIMER	, // PB 1 ** 52 ** SPI_SCK	
363
+	NOT_ON_TIMER	, // PB 0 ** 53 ** SPI_SS	
364
+	NOT_ON_TIMER	, // PF 0 ** 54 ** A0	
365
+	NOT_ON_TIMER	, // PF 1 ** 55 ** A1	
366
+	NOT_ON_TIMER	, // PF 2 ** 56 ** A2	
367
+	NOT_ON_TIMER	, // PF 3 ** 57 ** A3	
368
+	NOT_ON_TIMER	, // PF 4 ** 58 ** A4	
369
+	NOT_ON_TIMER	, // PF 5 ** 59 ** A5	
370
+	NOT_ON_TIMER	, // PF 6 ** 60 ** A6	
371
+	NOT_ON_TIMER	, // PF 7 ** 61 ** A7	
372
+	NOT_ON_TIMER	, // PK 0 ** 62 ** A8	
373
+	NOT_ON_TIMER	, // PK 1 ** 63 ** A9	
374
+	NOT_ON_TIMER	, // PK 2 ** 64 ** A10	
375
+	NOT_ON_TIMER	, // PK 3 ** 65 ** A11	
376
+	NOT_ON_TIMER	, // PK 4 ** 66 ** A12	
377
+	NOT_ON_TIMER	, // PK 5 ** 67 ** A13	
378
+	NOT_ON_TIMER	, // PK 6 ** 68 ** A14	
379
+	NOT_ON_TIMER	, // PK 7 ** 69 ** A15	
380
+};
381
+#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
64 382
 // these arrays map port names (e.g. port B) to the
65 383
 // appropriate addresses for various functions (e.g. reading
66 384
 // and writing)
67
-const uint8_t PROGMEM port_to_mode_PGM[] =
385
+const uint16_t PROGMEM port_to_mode_PGM[] =
68 386
 {
69
-	NOT_A_PORT,
70
-	(uint8_t) (uint16_t) &DDRA,
71
-	(uint8_t) (uint16_t) &DDRB,
72
-	(uint8_t) (uint16_t) &DDRC,
73
-	(uint8_t) (uint16_t) &DDRD,
387
+        NOT_A_PORT,
388
+    &DDRA,
389
+        &DDRB,
390
+        &DDRC,
391
+        &DDRD,
74 392
 };
75 393
 
76
-const uint8_t PROGMEM port_to_output_PGM[] =
394
+const uint16_t PROGMEM port_to_output_PGM[] =
395
+{
396
+        NOT_A_PORT,
397
+        &PORTA,
398
+        &PORTB,
399
+        &PORTC,
400
+        &PORTD,
401
+};
402
+const uint16_t PROGMEM port_to_input_PGM[] =
403
+{
404
+        NOT_A_PORT,
405
+        &PINA,
406
+        &PINB,
407
+        &PINC,
408
+        &PIND,
409
+};
410
+const uint8_t PROGMEM digital_pin_to_port_PGM[] =
411
+{
412
+        PB, /* 0 */
413
+        PB,
414
+        PB,
415
+        PB,
416
+        PB,
417
+        PB,
418
+        PB,
419
+        PB,
420
+        PD, /* 8 */
421
+        PD,
422
+        PD,
423
+        PD,
424
+        PD,
425
+        PD,
426
+        PD,
427
+        PD,
428
+        PC, /* 16 */
429
+        PC,
430
+        PC,
431
+        PC,
432
+        PC,
433
+        PC,
434
+        PC,
435
+        PC,
436
+        PA, /* 24 */
437
+        PA,
438
+        PA,
439
+        PA,
440
+        PA,
441
+        PA,
442
+        PA,
443
+        PA  /* 31 */
444
+};
445
+const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
446
+{
447
+        _BV(0), /* 0, port B */
448
+        _BV(1),
449
+        _BV(2),
450
+        _BV(3),
451
+        _BV(4),
452
+        _BV(5),
453
+        _BV(6),
454
+        _BV(7),
455
+        _BV(0), /* 8, port D */
456
+        _BV(1),
457
+        _BV(2),
458
+        _BV(3),
459
+        _BV(4),
460
+        _BV(5),
461
+        _BV(6),
462
+        _BV(7),
463
+        _BV(0), /* 16, port C */
464
+        _BV(1),
465
+        _BV(2),
466
+        _BV(3),
467
+        _BV(4),
468
+        _BV(5),
469
+        _BV(6),
470
+        _BV(7),
471
+        _BV(7), /* 24, port A */
472
+        _BV(6),
473
+        _BV(5),
474
+        _BV(4),
475
+        _BV(3),
476
+        _BV(2),
477
+        _BV(1),
478
+        _BV(0)
479
+};
480
+const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
77 481
 {
482
+        NOT_ON_TIMER,   /* 0  - PB0 */
483
+        NOT_ON_TIMER,   /* 1  - PB1 */
484
+        NOT_ON_TIMER,   /* 2  - PB2 */
485
+        TIMER0A,        /* 3  - PB3 */
486
+        TIMER0B,                /* 4  - PB4 */
487
+        NOT_ON_TIMER,   /* 5  - PB5 */
488
+        NOT_ON_TIMER,   /* 6  - PB6 */
489
+        NOT_ON_TIMER,   /* 7  - PB7 */
490
+        NOT_ON_TIMER,   /* 8  - PD0 */
491
+        NOT_ON_TIMER,   /* 9  - PD1 */
492
+        NOT_ON_TIMER,   /* 10 - PD2 */
493
+        NOT_ON_TIMER,   /* 11 - PD3 */
494
+        TIMER1B,        /* 12 - PD4 */
495
+        TIMER1A,        /* 13 - PD5 */
496
+        TIMER2B,        /* 14 - PD6 */
497
+        TIMER2A,        /* 15 - PD7 */
498
+        NOT_ON_TIMER,   /* 16 - PC0 */
499
+        NOT_ON_TIMER,   /* 17 - PC1 */
500
+        NOT_ON_TIMER,   /* 18 - PC2 */
501
+        NOT_ON_TIMER,   /* 19 - PC3 */
502
+        NOT_ON_TIMER,   /* 20 - PC4 */
503
+        NOT_ON_TIMER,   /* 21 - PC5 */
504
+        NOT_ON_TIMER,   /* 22 - PC6 */
505
+        NOT_ON_TIMER,   /* 23 - PC7 */
506
+        NOT_ON_TIMER,   /* 24 - PA0 */
507
+        NOT_ON_TIMER,   /* 25 - PA1 */
508
+        NOT_ON_TIMER,   /* 26 - PA2 */
509
+        NOT_ON_TIMER,   /* 27 - PA3 */
510
+        NOT_ON_TIMER,   /* 28 - PA4 */
511
+        NOT_ON_TIMER,   /* 29 - PA5 */
512
+        NOT_ON_TIMER,   /* 30 - PA6 */
513
+        NOT_ON_TIMER   /* 31 - PA7 */
514
+};
515
+
516
+#else
517
+// these arrays map port names (e.g. port B) to the
518
+// appropriate addresses for various functions (e.g. reading
519
+// and writing)
520
+const uint16_t PROGMEM port_to_mode_PGM[] = {
521
+	NOT_A_PORT,
78 522
 	NOT_A_PORT,
79
-	(uint8_t) (uint16_t) &PORTA,
80
-	(uint8_t) (uint16_t) &PORTB,
81
-	(uint8_t) (uint16_t) &PORTC,
82
-	(uint8_t) (uint16_t) &PORTD,
523
+	&DDRB,
524
+	&DDRC,
525
+	&DDRD,
83 526
 };
84 527
 
85
-const uint8_t PROGMEM port_to_input_PGM[] =
86
-{
528
+const uint16_t PROGMEM port_to_output_PGM[] = {
87 529
 	NOT_A_PORT,
88
-	(uint8_t) (uint16_t) &PINA,
89
-	(uint8_t) (uint16_t) &PINB,
90
-	(uint8_t) (uint16_t) &PINC,
91
-	(uint8_t) (uint16_t) &PIND,
530
+	NOT_A_PORT,
531
+	&PORTB,
532
+	&PORTC,
533
+	&PORTD,
92 534
 };
93 535
 
94
-const uint8_t PROGMEM digital_pin_to_port_PGM[] =
95
-{
96
-	PB, /* 0 */
97
-	PB,
98
-	PB,
99
-	PB,
100
-	PB,
101
-	PB,
102
-	PB,
103
-	PB,
104
-	PD, /* 8 */
536
+const uint16_t PROGMEM port_to_input_PGM[] = {
537
+	NOT_A_PORT,
538
+	NOT_A_PORT,
539
+	&PINB,
540
+	&PINC,
541
+	&PIND,
542
+};
543
+
544
+const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
545
+	PD, /* 0 */
105 546
 	PD,
106 547
 	PD,
107 548
 	PD,
@@ -109,27 +550,22 @@ const uint8_t PROGMEM digital_pin_to_port_PGM[] =
109 550
 	PD,
110 551
 	PD,
111 552
 	PD,
112
-	PC, /* 16 */
113
-	PC,
553
+	PB, /* 8 */
554
+	PB,
555
+	PB,
556
+	PB,
557
+	PB,
558
+	PB,
559
+	PC, /* 14 */
114 560
 	PC,
115 561
 	PC,
116 562
 	PC,
117 563
 	PC,
118
-   	PC,
119 564
 	PC,
120
-	PA, /* 24 */
121
-	PA,
122
-	PA,
123
-	PA,
124
-	PA,
125
-	PA,
126
-	PA,
127
-	PA  /* 31 */
128 565
 };
129 566
 
130
-const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
131
-{
132
-	_BV(0), /* 0, port B */
567
+const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
568
+	_BV(0), /* 0, port D */
133 569
 	_BV(1),
134 570
 	_BV(2),
135 571
 	_BV(3),
@@ -137,64 +573,55 @@ const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] =
137 573
 	_BV(5),
138 574
 	_BV(6),
139 575
 	_BV(7),
140
-	_BV(0), /* 8, port D */
576
+	_BV(0), /* 8, port B */
141 577
 	_BV(1),
142 578
 	_BV(2),
143 579
 	_BV(3),
144 580
 	_BV(4),
145 581
 	_BV(5),
146
-	_BV(6),
147
-	_BV(7),
148
-	_BV(0), /* 16, port C */
582
+	_BV(0), /* 14, port C */
149 583
 	_BV(1),
150 584
 	_BV(2),
151 585
 	_BV(3),
152 586
 	_BV(4),
153 587
 	_BV(5),
154
-	_BV(6),
155
-	_BV(7),
156
-	_BV(7), /* 24, port A */
157
-	_BV(6),
158
-	_BV(5),
159
-	_BV(4),
160
-	_BV(3),
161
-	_BV(2),
162
-	_BV(1),
163
-	_BV(0)
164 588
 };
165 589
 
166
-const uint8_t PROGMEM digital_pin_to_timer_PGM[] =
167
-{
168
-	NOT_ON_TIMER, 	/* 0  - PB0 */
169
-	NOT_ON_TIMER, 	/* 1  - PB1 */
170
-	NOT_ON_TIMER, 	/* 2  - PB2 */
171
-	TIMER0A,     	/* 3  - PB3 */
172
-	TIMER0B, 		/* 4  - PB4 */
173
-	NOT_ON_TIMER, 	/* 5  - PB5 */
174
-	NOT_ON_TIMER, 	/* 6  - PB6 */
175
-	NOT_ON_TIMER,	/* 7  - PB7 */
176
-	NOT_ON_TIMER, 	/* 8  - PD0 */
177
-	NOT_ON_TIMER, 	/* 9  - PD1 */
178
-	NOT_ON_TIMER, 	/* 10 - PD2 */
179
-	NOT_ON_TIMER, 	/* 11 - PD3 */
180
-	TIMER1B,     	/* 12 - PD4 */
181
-	TIMER1A,     	/* 13 - PD5 */
182
-	TIMER2B,     	/* 14 - PD6 */
183
-	TIMER2A,     	/* 15 - PD7 */
184
-	NOT_ON_TIMER, 	/* 16 - PC0 */
185
-	NOT_ON_TIMER,   /* 17 - PC1 */
186
-	NOT_ON_TIMER,   /* 18 - PC2 */
187
-	NOT_ON_TIMER,   /* 19 - PC3 */
188
-	NOT_ON_TIMER,   /* 20 - PC4 */
189
-	NOT_ON_TIMER,   /* 21 - PC5 */
190
-	NOT_ON_TIMER,   /* 22 - PC6 */
191
-	NOT_ON_TIMER,   /* 23 - PC7 */
192
-	NOT_ON_TIMER,   /* 24 - PA0 */
193
-	NOT_ON_TIMER,   /* 25 - PA1 */
194
-	NOT_ON_TIMER,   /* 26 - PA2 */
195
-	NOT_ON_TIMER,   /* 27 - PA3 */
196
-	NOT_ON_TIMER,   /* 28 - PA4 */
197
-	NOT_ON_TIMER,   /* 29 - PA5 */
198
-	NOT_ON_TIMER,   /* 30 - PA6 */
199
-	NOT_ON_TIMER   /* 31 - PA7 */
590
+const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
591
+	NOT_ON_TIMER, /* 0 - port D */
592
+	NOT_ON_TIMER,
593
+	NOT_ON_TIMER,
594
+	// on the ATmega168, digital pin 3 has hardware pwm
595
+#if defined(__AVR_ATmega8__)
596
+	NOT_ON_TIMER,
597
+#else
598
+	TIMER2B,
599
+#endif
600
+	NOT_ON_TIMER,
601
+	// on the ATmega168, digital pins 5 and 6 have hardware pwm
602
+#if defined(__AVR_ATmega8__)
603
+	NOT_ON_TIMER,
604
+	NOT_ON_TIMER,
605
+#else
606
+	TIMER0B,
607
+	TIMER0A,
608
+#endif
609
+	NOT_ON_TIMER,
610
+	NOT_ON_TIMER, /* 8 - port B */
611
+	TIMER1A,
612
+	TIMER1B,
613
+#if defined(__AVR_ATmega8__)
614
+	TIMER2,
615
+#else
616
+	TIMER2A,
617
+#endif
618
+	NOT_ON_TIMER,
619
+	NOT_ON_TIMER,
620
+	NOT_ON_TIMER,
621
+	NOT_ON_TIMER, /* 14 - port C */
622
+	NOT_ON_TIMER,
623
+	NOT_ON_TIMER,
624
+	NOT_ON_TIMER,
625
+	NOT_ON_TIMER,
200 626
 };
627
+#endif

+ 32
- 8
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/pins_arduino.h ファイルの表示

@@ -39,19 +39,43 @@
39 39
 #define TIMER2A 6
40 40
 #define TIMER2B 7
41 41
 
42
+#define TIMER3A 8
43
+#define TIMER3B 9
44
+#define TIMER3C 10
45
+#define TIMER4A 11
46
+#define TIMER4B 12
47
+#define TIMER4C 13
48
+#define TIMER5A 14
49
+#define TIMER5B 15
50
+#define TIMER5C 16
51
+
52
+#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
53
+const static uint8_t SS   = 53;
54
+const static uint8_t MOSI = 51;
55
+const static uint8_t MISO = 50;
56
+const static uint8_t SCK  = 52;
57
+#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
42 58
 const static uint8_t SS   = 4;
43 59
 const static uint8_t MOSI = 5;
44 60
 const static uint8_t MISO = 6;
45 61
 const static uint8_t SCK  = 7;
46 62
 
47
-extern const uint8_t PROGMEM port_to_mode_PGM[];
48
-extern const uint8_t PROGMEM port_to_input_PGM[];
49
-extern const uint8_t PROGMEM port_to_output_PGM[];
63
+#else
64
+const static uint8_t SS   = 10;
65
+const static uint8_t MOSI = 11;
66
+const static uint8_t MISO = 12;
67
+const static uint8_t SCK  = 13;
68
+#endif
69
+
70
+// On the ATmega1280, the addresses of some of the port registers are
71
+// greater than 255, so we can't store them in uint8_t's.
72
+extern const uint16_t PROGMEM port_to_mode_PGM[];
73
+extern const uint16_t PROGMEM port_to_input_PGM[];
74
+extern const uint16_t PROGMEM port_to_output_PGM[];
50 75
 
51 76
 extern const uint8_t PROGMEM digital_pin_to_port_PGM[];
52
-extern const uint8_t PROGMEM digital_pin_to_bit_PGM[];
77
+// extern const uint8_t PROGMEM digital_pin_to_bit_PGM[];
53 78
 extern const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[];
54
-
55 79
 extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
56 80
 
57 81
 // Get the bit location within the hardware port of the given virtual pin.
@@ -63,8 +87,8 @@ extern const uint8_t PROGMEM digital_pin_to_timer_PGM[];
63 87
 #define digitalPinToBitMask(P) ( pgm_read_byte( digital_pin_to_bit_mask_PGM + (P) ) )
64 88
 #define digitalPinToTimer(P) ( pgm_read_byte( digital_pin_to_timer_PGM + (P) ) )
65 89
 #define analogInPinToBit(P) (P)
66
-#define portOutputRegister(P) ( (volatile uint8_t *)( (uint16_t) pgm_read_byte( port_to_output_PGM + (P))) )
67
-#define portInputRegister(P) ( (volatile uint8_t *)( (uint16_t) pgm_read_byte( port_to_input_PGM + (P))) )
68
-#define portModeRegister(P) ( (volatile uint8_t *)( (uint16_t) pgm_read_byte( port_to_mode_PGM + (P))) )
90
+#define portOutputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_output_PGM + (P))) )
91
+#define portInputRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_input_PGM + (P))) )
92
+#define portModeRegister(P) ( (volatile uint8_t *)( pgm_read_word( port_to_mode_PGM + (P))) )
69 93
 
70 94
 #endif

+ 4
- 2
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/wiring.h ファイルの表示

@@ -25,7 +25,6 @@
25 25
 #ifndef Wiring_h
26 26
 #define Wiring_h
27 27
 
28
-#include <math.h>
29 28
 #include <avr/io.h>
30 29
 #include <stdlib.h>
31 30
 #include "binary.h"
@@ -77,7 +76,10 @@ extern "C"{
77 76
 #define max(a,b) ((a)>(b)?(a):(b))
78 77
 #define abs(x) ((x)>0?(x):-(x))
79 78
 #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
80
-#define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
79
+
80
+// Removed to work with newer AVRLIBC
81
+//#define round(x)     ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
82
+
81 83
 #define radians(deg) ((deg)*DEG_TO_RAD)
82 84
 #define degrees(rad) ((rad)*RAD_TO_DEG)
83 85
 #define sq(x) ((x)*(x))

+ 4
- 2
ArduinoAddons/Arduino_0.xx/Sanguino/cores/arduino/wiring_private.h ファイルの表示

@@ -24,10 +24,10 @@
24 24
 
25 25
 #ifndef WiringPrivate_h
26 26
 #define WiringPrivate_h
27
-#include <math.h>
27
+
28 28
 #include <avr/io.h>
29 29
 #include <avr/interrupt.h>
30
-#include <util/delay.h>
30
+#include <avr/delay.h>
31 31
 #include <stdio.h>
32 32
 #include <stdarg.h>
33 33
 
@@ -55,6 +55,8 @@ extern "C"{
55 55
 
56 56
 #if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
57 57
 #define EXTERNAL_NUM_INTERRUPTS 8
58
+#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
59
+#define EXTERNAL_NUM_INTERRUPTS 3
58 60
 #else
59 61
 #define EXTERNAL_NUM_INTERRUPTS 2
60 62
 #endif

+ 114
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/ChangeLog ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 1607
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g.h
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 177
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_bitmap.c ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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)|(1<<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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 ファイルの表示

@@ -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 };

+ 0
- 0
ArduinoAddons/Arduino_0.xx/libraries/U8glib/utility/u8g_dev_uc1701_dogs102.c ファイルの表示


変更されたファイルが多すぎるため、一部のファイルは表示されません

読み込み中…
キャンセル
保存