├── .github
└── workflows
│ └── main.yml
├── LICENSE
├── POST_S76G.ino
├── README.md
├── documents
└── images
│ ├── mpu9250.jpg
│ ├── rak7200-1.JPG
│ ├── t-motion-2.jpg
│ ├── t-motion-3.jpg
│ ├── t-motion-30.jpg
│ ├── t-motion-31.jpg
│ └── t-motion-6.jpg
├── extras
└── SDK
│ └── s7678gsdk1_all_v0.0.4_with_gps.zip
└── libraries
└── U8g2
├── README.md
├── examples
├── full_buffer
│ ├── FPS
│ │ └── FPS.ino
│ ├── FontUsage
│ │ └── FontUsage.ino
│ ├── GraphicsTest
│ │ └── GraphicsTest.ino
│ ├── HelloWorld
│ │ └── HelloWorld.ino
│ ├── PrintUTF8
│ │ └── PrintUTF8.ino
│ ├── SelectionList
│ │ └── SelectionList.ino
│ ├── Shennong
│ │ └── Shennong.ino
│ └── U8g2Logo
│ │ └── U8g2Logo.ino
├── games
│ └── LittleRookChess
│ │ └── LittleRookChess.ino
├── page_buffer
│ ├── A2Printer
│ │ └── A2Printer.ino
│ ├── Chinese
│ │ └── Chinese.ino
│ ├── Clock
│ │ └── Clock.ino
│ ├── ContrastTest
│ │ └── ContrastTest.ino
│ ├── DirectAccess
│ │ └── DirectAccess.ino
│ ├── ExtUTF8
│ │ └── ExtUTF8.ino
│ ├── FPS
│ │ └── FPS.ino
│ ├── FlipMode
│ │ └── FlipMode.ino
│ ├── GraphicsTest
│ │ └── GraphicsTest.ino
│ ├── HelloWorld
│ │ └── HelloWorld.ino
│ ├── Japanese
│ │ └── Japanese.ino
│ ├── Korean
│ │ └── Korean.ino
│ ├── PowerSaveTest
│ │ └── PowerSaveTest.ino
│ ├── PrintHelloWorld
│ │ └── PrintHelloWorld.ino
│ ├── PrintProgmem
│ │ └── PrintProgmem.ino
│ ├── PrintUTF8
│ │ └── PrintUTF8.ino
│ ├── ScrollingText
│ │ └── ScrollingText.ino
│ ├── SelectionList
│ │ └── SelectionList.ino
│ ├── Shennong
│ │ └── Shennong.ino
│ ├── U8g2Logo
│ │ └── U8g2Logo.ino
│ ├── XBM
│ │ └── XBM.ino
│ └── XORTest
│ │ └── XORTest.ino
└── u8x8
│ ├── ArduboyTest
│ └── ArduboyTest.ino
│ ├── FlipMode
│ └── FlipMode.ino
│ ├── GraphicsTest
│ └── GraphicsTest.ino
│ ├── HelloWorld
│ └── HelloWorld.ino
│ └── MessageBox
│ └── MessageBox.ino
├── extras
└── ChangeLog
├── keywords.txt
├── library.properties
└── src
├── U8g2lib.h
├── U8x8lib.cpp
├── U8x8lib.h
└── clib
├── u8g2.h
├── u8g2_bitmap.c
├── u8g2_box.c
├── u8g2_buffer.c
├── u8g2_circle.c
├── u8g2_cleardisplay.c
├── u8g2_d_memory.c
├── u8g2_d_setup.c
├── u8g2_font.c
├── u8g2_fonts.c
├── u8g2_hvline.c
├── u8g2_input_value.c
├── u8g2_intersection.c
├── u8g2_kerning.c
├── u8g2_line.c
├── u8g2_ll_hvline.c
├── u8g2_message.c
├── u8g2_polygon.c
├── u8g2_selection_list.c
├── u8g2_setup.c
├── u8x8.h
├── u8x8_8x8.c
├── u8x8_byte.c
├── u8x8_cad.c
├── u8x8_d_a2printer.c
├── u8x8_d_il3820_296x128.c
├── u8x8_d_ist3020.c
├── u8x8_d_ks0108.c
├── u8x8_d_lc7981.c
├── u8x8_d_ld7032_60x32.c
├── u8x8_d_ls013b7dh03.c
├── u8x8_d_max7219.c
├── u8x8_d_pcd8544_84x48.c
├── u8x8_d_pcf8812.c
├── u8x8_d_pcf8814_hx1230.c
├── u8x8_d_sbn1661.c
├── u8x8_d_sed1330.c
├── u8x8_d_sh1107.c
├── u8x8_d_ssd1305.c
├── u8x8_d_ssd1306_128x32.c
├── u8x8_d_ssd1306_128x64_noname.c
├── u8x8_d_ssd1306_64x32.c
├── u8x8_d_ssd1306_64x48.c
├── u8x8_d_ssd1306_96x16.c
├── u8x8_d_ssd1309.c
├── u8x8_d_ssd1322.c
├── u8x8_d_ssd1325.c
├── u8x8_d_ssd1326.c
├── u8x8_d_ssd1327.c
├── u8x8_d_ssd1329.c
├── u8x8_d_ssd1606_172x72.c
├── u8x8_d_ssd1607_200x200.c
├── u8x8_d_st75256.c
├── u8x8_d_st7565.c
├── u8x8_d_st7567.c
├── u8x8_d_st7588.c
├── u8x8_d_st7920.c
├── u8x8_d_t6963.c
├── u8x8_d_uc1601.c
├── u8x8_d_uc1604.c
├── u8x8_d_uc1608.c
├── u8x8_d_uc1610.c
├── u8x8_d_uc1611.c
├── u8x8_d_uc1617.c
├── u8x8_d_uc1638.c
├── u8x8_d_uc1701_dogs102.c
├── u8x8_d_uc1701_mini12864.c
├── u8x8_debounce.c
├── u8x8_display.c
├── u8x8_fonts.c
├── u8x8_gpio.c
├── u8x8_input_value.c
├── u8x8_message.c
├── u8x8_selection_list.c
├── u8x8_setup.c
├── u8x8_string.c
├── u8x8_u16toa.c
└── u8x8_u8toa.c
/.github/workflows/main.yml:
--------------------------------------------------------------------------------
1 | # This is a basic workflow to help you get started with Actions
2 |
3 | name: build
4 |
5 | # Controls when the workflow will run
6 | on:
7 | # Triggers the workflow on push or pull request events but only for the master branch
8 | push:
9 | branches: [ master ]
10 |
11 | # Allows you to run this workflow manually from the Actions tab
12 | workflow_dispatch:
13 |
14 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel
15 | jobs:
16 | # This workflow contains a single job called "build"
17 | build:
18 | # The type of runner that the job will run on
19 | runs-on: ubuntu-latest
20 |
21 | strategy:
22 | matrix:
23 | board: ['STM32:stm32:Nucleo_64']
24 |
25 | env:
26 | ARDUINO_IDE_VERSION: 1.8.13
27 | BOARD: ${{ matrix.board }}
28 |
29 | # Steps represent a sequence of tasks that will be executed as part of the job
30 | steps:
31 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
32 | - uses: actions/checkout@v2
33 |
34 | - name: Setup tmate session
35 | uses: mxschmitt/action-tmate@v3
36 |
37 | # Runs a set of commands using the runners shell
38 | - name: Run before_install
39 | run: |
40 | /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16
41 | sleep 3
42 | export DISPLAY=:1.0
43 | wget http://downloads.arduino.cc/arduino-$ARDUINO_IDE_VERSION-linux64.tar.xz ;
44 | tar xf arduino-$ARDUINO_IDE_VERSION-linux64.tar.xz ;
45 | rm arduino-$ARDUINO_IDE_VERSION-linux64.tar.xz ;
46 | sudo mv arduino-$ARDUINO_IDE_VERSION /usr/local/share/arduino ;
47 | sudo ln -s /usr/local/share/arduino/arduino /usr/local/bin/arduino ;
48 |
49 | - name: Run install
50 | run: |
51 | mkdir $HOME/Arduino ;
52 | ln -s $PWD/libraries $HOME/Arduino/libraries ;
53 | if [[ "$BOARD" =~ "STM32:stm32:" ]]; then
54 | arduino --pref "boardsmanager.additional.urls=https://github.com/stm32duino/BoardManagerFiles/raw/07bcfb337e4c9abe83a029b39e33ddff5a6df2ef/STM32/package_stm_index.json" --save-prefs ;
55 | arduino --install-boards STM32:stm32 ;
56 | arduino --board $BOARD --save-prefs ;
57 | if [[ "$BOARD" =~ "STM32:stm32:Nucleo_64" ]]; then
58 | arduino --pref "custom_pnum=Nucleo_64_NUCLEO_L073RZ" --save-prefs ;
59 | arduino --pref "custom_opt=Nucleo_64_osstd" --save-prefs ;
60 | arduino --pref "custom_rtlib=Nucleo_64_nano" --save-prefs ;
61 | arduino --pref "custom_usb=Nucleo_64_CDCgen" --save-prefs ;
62 | arduino --pref "custom_xserial=Nucleo_64_none" --save-prefs ;
63 | arduino --pref "custom_xusb=Nucleo_64_FS" --save-prefs ;
64 | fi ;
65 | cd $GITHUB_WORKSPACE ;
66 | fi
67 |
68 | - name: Run script
69 | run: |
70 | if [[ "$BOARD" =~ "STM32:stm32:" ]]; then
71 | arduino --verify --verbose-build --board $BOARD POST_S76G.ino ;
72 | fi ;
73 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # POST_S76G [](https://github.com/lyusupov/POST_S76G/actions/workflows/main.yml)
2 |
3 | Power-on Self Test for _(AcSiP S76G based)_ LilyGO® & SoftRF **T-Motion** LoRaWAN GNSS tracker and **T-Impulse** wristband
4 |
5 | * [Illustrations](https://github.com/lyusupov/POST_S76G/blob/master/README.md#illustrations)
6 | * [Sketch build instructions](https://github.com/lyusupov/POST_S76G/blob/master/README.md#sketch-build-instructions)
7 | * [Credits](https://github.com/lyusupov/POST_S76G/blob/master/README.md#credits)
8 | * [More information](https://github.com/lyusupov/POST_S76G/blob/master/README.md#more-information)
9 |
10 | # Illustrations
11 |
12 | * Serial console log (115200, 8N1)
13 |
14 |
15 | ## T-Motion
16 |
17 | 
18 |
19 |
20 |
21 | ## T-Impulse
22 |
23 | 
24 |
25 |
26 |
27 | * 0.96" I2C OLED display ( _if_ _connected_ )
28 |
29 |
30 |
31 | 
32 |
33 |
34 |
35 | * 0.49" I2C OLED display
36 |
37 |
38 |
39 | 
40 |
41 |
42 |
43 | # Sketch build instructions
44 |
45 | You should have [**STM32CubeProg**](https://www.st.com/en/development-tools/stm32cubeprog.html) been pre-installed in order to program your T-Motion board or T-Impulse wristband.
46 | Press **BOOT** button on your T-Motion _(or T-Impulse)_ device, plug it into a PC/laptop USB slot, then release.
47 |
48 | 1. Follow [these official instructions](https://github.com/stm32duino/wiki/wiki/Getting-Started)
49 | to install Arduino IDE and [ **stable** Arduino STM32 Core](https://github.com/stm32duino/Arduino_Core_STM32/releases/tag/1.9.0) (1.9.0)
50 | 2. start **Arduino** application
51 | 3. open **POST_S76G** sketch from _File_ -> _Open_ menu
52 | 4. Select _Tools_ -> _Board_ -> _Nucleo_64_
53 | 5. Select _Tools_ -> _Optimize_ -> _Smallest_ _(-Os default)_
54 | 6. Select _Tools_ -> _Board_ _part_ _number_ -> _Nucleo_ _L073RZ_
55 | 7. Select _Tools_ -> _C_ _Runtime_ _library_ -> _Newlib_ _Nano_ _(default)_
56 | 8. Select _Tools_ -> _USB_ _speed_ _(if available)_ -> _Low/Full_ _Speed_
57 | 9. Select _Tools_ -> _USB_ _support_ _(if available)_ -> _CDC_ _(generic_ _'Serial'_ _supersede_ _U(S)ART)_
58 | 10. Select _Tools_ -> _U(S)ART_ _support_ -> _Enabled_ _(no_ _generic_ _'Serial')_
59 | 11. Select _Tools_ -> _Upload_ _method_ -> _STM32CubeProgrammer_ _(DFU)_
60 | 12. Select _Tools_ -> _Port_ -> ````
61 | 13. Build and upload the sketch using _Sketch_ -> _Upload_
62 |
63 | # Credits
64 |
65 | Name|Subject
66 | ---|---
67 | [LilyGO company](http://www.lilygo.cn/)|[TTGO T-Motion](http://www.lilygo.cn/prod_view.aspx?Id=1254) and [T-Impulse](https://s.click.aliexpress.com/e/_AVK1N4)
68 | [Frederic Pillon](https://github.com/fpistm)|[Arduino Core for STM32](https://github.com/stm32duino/Arduino_Core_STM32)
69 | [Oliver Kraus](https://github.com/olikraus)|[U8g2 monochrome LCD, OLED and eInk library](https://github.com/olikraus/u8g2)
70 |
71 | # More information
72 |
73 | 1. [List of AcSiP S7xx resources](https://github.com/lyusupov/POST_S76G/wiki/AcSiP-S7xG-resources)
74 |
75 |
--------------------------------------------------------------------------------
/documents/images/mpu9250.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lyusupov/POST_S76G/9f51ff1edaf0adfae1e6cb3535eadefa8c421b45/documents/images/mpu9250.jpg
--------------------------------------------------------------------------------
/documents/images/rak7200-1.JPG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lyusupov/POST_S76G/9f51ff1edaf0adfae1e6cb3535eadefa8c421b45/documents/images/rak7200-1.JPG
--------------------------------------------------------------------------------
/documents/images/t-motion-2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lyusupov/POST_S76G/9f51ff1edaf0adfae1e6cb3535eadefa8c421b45/documents/images/t-motion-2.jpg
--------------------------------------------------------------------------------
/documents/images/t-motion-3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lyusupov/POST_S76G/9f51ff1edaf0adfae1e6cb3535eadefa8c421b45/documents/images/t-motion-3.jpg
--------------------------------------------------------------------------------
/documents/images/t-motion-30.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lyusupov/POST_S76G/9f51ff1edaf0adfae1e6cb3535eadefa8c421b45/documents/images/t-motion-30.jpg
--------------------------------------------------------------------------------
/documents/images/t-motion-31.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lyusupov/POST_S76G/9f51ff1edaf0adfae1e6cb3535eadefa8c421b45/documents/images/t-motion-31.jpg
--------------------------------------------------------------------------------
/documents/images/t-motion-6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lyusupov/POST_S76G/9f51ff1edaf0adfae1e6cb3535eadefa8c421b45/documents/images/t-motion-6.jpg
--------------------------------------------------------------------------------
/extras/SDK/s7678gsdk1_all_v0.0.4_with_gps.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lyusupov/POST_S76G/9f51ff1edaf0adfae1e6cb3535eadefa8c421b45/extras/SDK/s7678gsdk1_all_v0.0.4_with_gps.zip
--------------------------------------------------------------------------------
/libraries/U8g2/README.md:
--------------------------------------------------------------------------------
1 | # U8g2_Arduino: Arduino Monochrome Graphics Library
2 |
3 | 
4 |
5 | U8glib V2 library for Arduino
6 |
7 | Description: https://github.com/olikraus/u8g2/wiki
8 |
9 | Issue Tracker: https://github.com/olikraus/u8g2/issues
10 |
11 | Download (2.21.8): https://github.com/olikraus/U8g2_Arduino/archive/master.zip
12 |
13 |
--------------------------------------------------------------------------------
/libraries/U8g2/examples/page_buffer/A2Printer/A2Printer.ino:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | A2Printer.ino
4 |
5 | This is a special example for the A2 Thermo Printer
6 | This example can NOT be used with LCDs and OLEDs
7 |
8 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
9 |
10 | Copyright (c) 2016, 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 | // use this serial interface
40 | #define PRINTER_SERIAL Serial
41 | // #define PRINTER_SERIAL Serial1
42 |
43 |
44 | #include
45 | #include
46 |
47 | #ifdef U8X8_HAVE_HW_SPI
48 | #include
49 | #endif
50 | #ifdef U8X8_HAVE_HW_I2C
51 | #include
52 | #endif
53 |
54 |
55 |
56 | /* define our own serial function, this will be assigned later */
57 |
58 | extern "C" uint8_t u8x8_byte_arduino_serial(u8x8_t *u8g2, uint8_t msg, uint8_t arg_int, void *arg_ptr)
59 | {
60 | uint8_t *data;
61 |
62 | switch(msg)
63 | {
64 | case U8X8_MSG_BYTE_SEND:
65 | data = (uint8_t *)arg_ptr;
66 | while( arg_int > 0 )
67 | {
68 | while(PRINTER_SERIAL.available() > 0)
69 | PRINTER_SERIAL.read();
70 | PRINTER_SERIAL.write((uint8_t)*data);
71 | data++;
72 | arg_int--;
73 | }
74 | break;
75 |
76 | case U8X8_MSG_BYTE_INIT:
77 | delay(1000);
78 | PRINTER_SERIAL.begin(19200);
79 | /* send something.... */
80 | //PRINTER_SERIAL.begin(9600);
81 | PRINTER_SERIAL.write(27); /* ESC */
82 | PRINTER_SERIAL.write(64); /* @ --> reset printer */
83 | delay(1000);
84 |
85 | break;
86 |
87 | case U8X8_MSG_BYTE_SET_DC:
88 | break;
89 |
90 | case U8X8_MSG_BYTE_START_TRANSFER:
91 | break;
92 |
93 | case U8X8_MSG_BYTE_END_TRANSFER:
94 | break;
95 |
96 | default:
97 | return 0;
98 | }
99 | return 1;
100 | }
101 |
102 | /* define a u8g2 object just with the base class */
103 | /* the baseclass will be configured for the A2 printer in the setup() procedure */
104 | class U8G2 u8g2;
105 |
106 | void setup(void) {
107 |
108 | u8g2_Setup_a2printer_384x240_1( /* several different a2 printer procs exist... */
109 | u8g2.getU8g2(), /* this is a c call, so use the u8g2 struct instead of the class */
110 | U8G2_R0, /* this defines the usual rotation of the bitmap */
111 | u8x8_byte_arduino_serial, /* this is the new procedure from above */
112 | u8x8_gpio_and_delay_arduino); /* standard arduino low level proc, used only for delay */
113 |
114 | u8g2.beginSimple(); /* Do not clear the display, wake is not required */
115 | }
116 |
117 | #define XO 10
118 |
119 | void drawLogo(void)
120 | {
121 |
122 | u8g2.setFontMode(1); // Transparent
123 | u8g2.setFontDirection(0);
124 | u8g2.setFont(u8g2_font_inb24_mf);
125 | u8g2.drawStr(0+XO, 30, "U");
126 |
127 | u8g2.setFontDirection(1);
128 | u8g2.setFont(u8g2_font_inb30_mn);
129 | u8g2.drawStr(21+XO,8,"8");
130 |
131 | u8g2.setFontDirection(0);
132 | u8g2.setFont(u8g2_font_inb24_mf);
133 | u8g2.drawStr(51+XO,30,"g");
134 | u8g2.drawStr(67+XO,30,"\xb2");
135 |
136 | u8g2.drawHLine(2+XO, 35, 47);
137 | u8g2.drawHLine(3+XO, 36, 47);
138 | u8g2.drawVLine(45+XO, 32, 12);
139 | u8g2.drawVLine(46+XO, 33, 12);
140 | }
141 |
142 | void drawURL(void)
143 | {
144 | u8g2.setFont(u8g2_font_6x12_tr);
145 | u8g2.drawStr(1+XO,54,"github.com/olikraus/u8g2");
146 | }
147 |
148 | void loop(void) {
149 | u8g2.firstPage();
150 | do {
151 | drawLogo();
152 | drawURL();
153 |
154 | /* worst case heating test */
155 | u8g2.drawRBox(4,90,384-8,20, 8);
156 |
157 | /* heating test with some text */
158 | u8g2.setFont(u8g2_font_inb24_mf);
159 | u8g2.drawStr(10,160,"Hello World!");
160 |
161 | /* draw a frame around the picture */
162 | u8g2.drawFrame(0,0,384,240);
163 | u8g2.drawFrame(1,1,384-2,240-2);
164 | } while ( u8g2.nextPage() );
165 | delay(1000);
166 | }
167 |
168 |
--------------------------------------------------------------------------------
/libraries/U8g2/examples/u8x8/ArduboyTest/ArduboyTest.ino:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | Arduboy.ino
4 |
5 | Arduboy Test Example with U8x8
6 |
7 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
8 |
9 | Copyright (c) 2016, 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
39 | #include
40 | #include
41 |
42 | #ifdef U8X8_HAVE_HW_SPI
43 | #include
44 | #endif
45 |
46 | // Arduboy 10 (Production, Kickstarter Edition)
47 | U8X8_SSD1306_128X64_NONAME_4W_HW_SPI u8x8(/* cs=*/ 12, /* dc=*/ 4, /* reset=*/ 6);
48 |
49 | ArduboyCore arduboyCore;
50 | ArduboyAudio arduboyAudio;
51 | ArduboyTunes arduboyTunes;
52 |
53 | void setup(void)
54 | {
55 | //u8x8.begin(/*Select=*/ A0, /*Right/Next=*/ 5, /*Left/Prev=*/ 9, /*Up=*/ 8, /*Down=*/ 10, /*Home/Cancel=*/ A1); // Arduboy DevKit
56 | u8x8.begin(/*Select=*/ 7, /*Right/Next=*/ A1, /*Left/Prev=*/ A2, /*Up=*/ A0, /*Down=*/ A3, /*Home/Cancel=*/ 8); // Arduboy 10 (Production)
57 |
58 | arduboyTunes.initChannel(PIN_SPEAKER_1);
59 | arduboyTunes.initChannel(PIN_SPEAKER_2);
60 | arduboyAudio.begin();
61 | }
62 |
63 | void msg(const char *txt)
64 | {
65 | u8x8.clear();
66 | u8x8.print(txt);
67 | }
68 |
69 | void loop(void)
70 | {
71 | static uint8_t c = 1;
72 | static uint8_t b = 0;
73 | u8x8.setFont(u8x8_font_chroma48medium8_r);
74 | c = u8x8.userInterfaceSelectionList("Arduboy Test\n", c, "LED Test\nButton Test\nSpeaker Test");
75 | if ( c == 1 )
76 | {
77 | msg("LED Test");
78 | arduboyCore.setRGBled(255, 0, 0);
79 | delay(500);
80 | arduboyCore.setRGBled(0, 255, 0); // green is not there ???
81 | delay(500);
82 | arduboyCore.setRGBled(0, 0, 255);
83 | delay(500);
84 | arduboyCore.setRGBled(0, 0, 0);
85 | }
86 | else if ( c == 2 )
87 | {
88 | u8x8.clear();
89 | for(;;)
90 | {
91 | u8x8.drawUTF8(0, 0, "Button Test");
92 | b = arduboyCore.buttonsState();
93 |
94 | u8x8.noInverse();
95 | if ( b & A_BUTTON )
96 | u8x8.inverse();
97 | u8x8.drawUTF8(0, 1, "A Button");
98 |
99 | u8x8.noInverse();
100 | if ( b & B_BUTTON )
101 | u8x8.inverse();
102 | u8x8.drawUTF8(0, 2, "B Button");
103 |
104 | u8x8.noInverse();
105 | if ( b & UP_BUTTON )
106 | u8x8.inverse();
107 | u8x8.drawUTF8(0, 3, "UP Button");
108 |
109 | u8x8.noInverse();
110 | if ( b & DOWN_BUTTON )
111 | u8x8.inverse();
112 | u8x8.drawUTF8(0, 4, "DOWN Button");
113 |
114 | u8x8.noInverse();
115 | if ( b & LEFT_BUTTON )
116 | u8x8.inverse();
117 | u8x8.drawUTF8(0, 5, "LEFT Button");
118 |
119 | u8x8.noInverse();
120 | if ( b & RIGHT_BUTTON )
121 | u8x8.inverse();
122 | u8x8.drawUTF8(0, 6, "RIGHT Button");
123 |
124 | u8x8.noInverse();
125 | u8x8.drawUTF8(0, 7, "Quit: A&B Button");
126 |
127 | if ( (b & A_BUTTON) && (b & B_BUTTON) )
128 | break;
129 | }
130 | }
131 | else if ( c == 3 )
132 | {
133 | u8x8.clear();
134 | u8x8.drawUTF8(0, 0, "Speaker Test");
135 | arduboyTunes.tone(1000, 1000);
136 | delay(1000);
137 | arduboyTunes.tone(2000, 1000);
138 | delay(1000);
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/libraries/U8g2/extras/ChangeLog:
--------------------------------------------------------------------------------
1 |
2 | https://github.com/olikraus/u8g2 ChangeLog
3 |
4 |
5 | 2016-04-30 v2.0.1 olikraus@gmail.com
6 | * Support for DOGS102, ST7920, SSD1306
7 | * Most graphics primitives are implemented
8 | 2016-05-15 v2.0.3 olikraus@gmail.com
9 | * Support for Adafruit FeatherWing 128x32 OLED
10 | * Added Wire.h support (I2C for SSD1306)
11 | * Successfully tested with Adafruit ESP8266 Feather Board (HW+SW I2C)
12 | * Successfully tested with Adafruit Feather M0 Basic Board (HW+SW I2C)
13 | 2016-06-12 v2.0.4 olikraus@gmail.com
14 | * Support for ST7565
15 | 2016-06-25 v2.0.6 olikraus@gmail.com
16 | * User interface functions
17 | * Little Rook Chess ported
18 | * ST7920 HW and SW SPI
19 | 2016-06-26 v2.0.7 olikraus@gmail.com
20 | * drawLine
21 | * GraphicsTest Example
22 | 2016-08-09 v2.1.5 olikraus@gmail.com
23 | * T6963 Support
24 | * Experimental Support for SSD1322 256x64
25 | * A2 Thermoprinter Support
26 | * Added several fonts from http://int10h.org/oldschool-pc-fonts/
27 | * Added Arabic, Greek and Cyrillic fonts.
28 | * Code cleanup (assert, spi modes, void * warning)
29 | 2016-08-17 v2.2.7 olikraus@gmail.com
30 | * U8x8: Upscale by 2 (Issue 41)
31 | * Fixed SSD1306 I2C procedures (mirror pixel in last tile column, issue 44)
32 | * Experimental support für mini12864 (pull request)
33 | * Use beginTransaction for SPI. This requires Arduino 1.6.0
34 | 2016-08-18 v2.3.2 olikraus@gmail.com
35 | * MINI12874; Fixed HW Flip Mode (pull request 49)
36 | * Fixed ST7920 HW SPI with very fast uC, issue 50
37 | * Improved HW SPI for SH1106 and SSD1306 displays
38 | * Fixed issue with missing fonts
39 | 2016-08-21 v2.4.1 olikraus@gmail.com
40 | * Fixed HW SPI Modes (issue 52)
41 | 2016-10-01 v2.5.2 olikraus@gmail.com
42 | * Added crox fonts (issue 57)
43 | * Support for RA8835 (issue 45)
44 | * Added support for SSD1322 and SSD1325
45 | * Added DrawXBMP (AVR: Assume bitmap in PROGMEM)
46 | * Added japanese fonts (issue 65)
47 | 2016-11-13 v2.6.3 olikraus@gmail.com
48 | * Added support for UC1610 (EA DOGXL160)
49 | * Use Wire.setClock() for improved HW I2C performance (issue 79). This
50 | requires Arduino IDE 1.6.0 or higher.
51 | * Added Thai Fonts (issue 73)
52 | * Added support for "\n" in the print function for u8x8 (issue 74)
53 | * Screen mirror option for U8g2 (issue 76)
54 | * Added support for second wire interface (Constructor postfix 2ND_HW_I2C)
55 | * Added support for UC1611 (EA DOGM240 and EA DOGXL240, issue 66)
56 | 2016-11-28 v2.7.5 olikraus@gmail.com
57 | * Added support for 0.66" 64x48 SSD1306 OLED (issue 89)
58 | * Support for UC1608 (issue 92)
59 | * Speed improvements for SW SPI und 8080 mode (issues 87, 90 and 95)
60 | * Fixed issue with ST7920 not using the optimized SW SPI procedures (issue 87)
61 | * Direct buffer API (issue 93)
62 | 2016-12-11 v2.8.4 olikraus@gmail.com
63 | * Increased contrast range for SSD1306 (issue 98)
64 | * Support for KS0108 (issue 88)
65 | * Support for UC1608 240x128 (issue 101)
66 | * Speed improvement (issue 96)
67 | 2016-12-12 v2.8.5 olikraus@gmail.com
68 | * Bugfix for issue 96 (issue 106)
69 | 2016-12-20 v2.9.1 olikraus@gmail.com
70 | * Speed improvement for AVR/KS0108 (issue 104)
71 | * Support for UC1604 (issue 111)
72 | * Support for PCD8544/Nokia Display (issue 107)
73 | * Change/fixed behavior of userInterfaceSelectionList (issue 112)
74 | 2016-12-23 v2.9.2 olikraus@gmail.com
75 | * Reverted the setup for SSD1306_NONAME to the original setup (undo issue 98)
76 | * Introduced SSD1306_VCOMH0 for the max range setup (issue 116)
77 | 2016-12-30 v2.10.1 olikraus@gmail.com
78 | * ST7565 LM6059 Display (issue 123)
79 | * SSD1606 eInk/ePaper Display (issue 100)
80 | * Documentation updates
81 | 2017-01-08 v2.11.4 olikraus@gmail.com
82 | * Support for LC7981 (issue 134)
83 | * Support for PCF8812 (issue 135)
84 | * Fixed wrong half-move notation in Little Rook Chess (issue 137)
85 | * Support for ST7567, Pax Instruments GLCD Shield (issue 138)
86 | * Support for NT7534 (issue 143)
87 | * Support for SSD1327, Seeedstudio OLED (issue 145)
88 | * Support for SSD1305 (issue 146)
89 | * Support for DOGM132 (issue 147)
90 | * Fixed a bug in the draw pixel procedure which appears in full buffer mode,
91 | if the display width is not a multiple of 8 (issue 148)
92 | * Added XOR mode (setDrawColor 2, issue 56)
93 | 2017-01-15 v2.12.6 olikraus@gmail.com
94 | * Support for SSD1309 (issue 113)
95 | * Enabled U8G2_HVLINE_SPEED_OPTIMIZATION (not sure why this was disabled)
96 | * Improved speed for ST7920 (up to 40%, issue 151)
97 | * Support for IST3020 (issue 153)
98 | 2017-02-07 v2.13.6 olikraus@gmail.com
99 | * Support for ST7588 (issue 154)
100 | * ESP8266: Avoid RAM copy of the fonts (issue 159)
101 | * Support for SSD1607 (issue 133)
102 | * Support for hardware pin remapping on the ESP8266 (issue 158)
103 | * Bugfix for the KS0108 support (issue 168)
104 | * More fonts: https://github.com/olikraus/u8g2/wiki/fntgrpnbp (issue 174)
105 | 2017-03-11 v2.14.7 olikraus@gmail.com
106 | * Bugfix: setFont does no longer resets the reference position (issue 195)
107 | * Support for ST7565 NHD C12864 (issue 186)
108 | * Support for SSD1329 128x96 OLED (issue 208)
109 | * Support for LC7981 240x128 (issue 193)
110 | * Performance improvement for the ST7920 (issue 200)
111 | 2017-05-22 v2.15.2 olikraus@gmail.com
112 | * Added setBitmapMode (pull request 220)
113 | Warning: Default behavior of drawXBM has changed in this release.
114 | * Increased SPI speed to 8MHz for SSD1306, SH1106 and SSD1322 (issue 215)
115 | * Added some more examples (issue 216)
116 | * Added Urdu, Bengali, Hebrew and Polish language fonts (issues 221, 246 and 266)
117 | * Added more examples (issue 216)
118 | * Updated code for NHD C12864 (issues 219 and 241)
119 | * Improved speed for HW SPI with SSD13xx OLEDs (issue 215)
120 | 2017-08-12 v2.16.9 olikraus@gmail.com
121 | * Fonts u8g2_font_unifont_t_korean1, u8g2_font_unifont_t_korean2 (issue 266)
122 | * Added support for 64128N ST7565 based display (issue 292)
123 | * Added extended fonts (_te, unicodes 32-701, issue 284)
124 | * Added support for MAX7219 (issue 280)
125 | * Performance optimization for SSD1322/25/27 (issue 302)
126 | * Fixed setContrast for SSD1322 (issue 328)
127 | * Support for 96x16 SSD1306 OLED (issue 295)
128 | * Fixed OldStandard-Bold fonts (osb, issue 306)
129 | * Support for SED1520/SBN1661 (issue 324)
130 | 2017-09-10 v2.17.11 olikraus@gmail.com
131 | * Additional _m_ and _h_ symbol fonts (issue 335)
132 | * Added parallel interfaces for several UC16xx devices (issue 339)
133 | * Support for IL3820, WaveShare 2.9" e-paper (issues 318 & 347)
134 | * Improved debounce algorithm (issue 338)
135 | * Power save mode for SSD1607 device (issue 352)
136 | 2017-09-30 v2.18.13 olikraus@gmail.com
137 | * Support for ST7567_JLX12864 (issue 365)
138 | * Support for UC1611 (no "s") (issue 339)
139 | * Fixed several issues related to the _F_ (full buffer) mode (issue 370)
140 | 2017-10-13 v2.19.8 olikraus@gmail.com
141 | * Support for UC1601 (issue 378)
142 | * Support for ESP32 I2C pin remapping (issue 377)
143 | * Support for ST75256 (SPI), JLX256128, JLX172104 (issue 163)
144 | * Added uw-ttyp0 fonts (issue 349)
145 | 2017-12-09 v2.20.13 olikraus@gmail.com
146 | * Bugfix for drawBitmap (issue 391)
147 | * I2C support for ST75256 (issue 384)
148 | * Support for SSD1327 128x128 display (issue 397)
149 | * Support for ST75256 JLX25664 display (issue 399)
150 | * Added keywords.txt (issue 402)
151 | * Experimental support for SSD1326 (issue 398)
152 | * Experimental alternative COM config for SSD1306 128x64 (issue 408)
153 | * New SH1106 init sequence (SH1106_WINSTAR, issue 316)
154 | * Support for SSD1322 NHD 128x64 (issue 412)
155 | * Fixed profont17 (issue 438)
156 | 2018-02-18 v2.21.8 olikraus@gmail.com
157 | * Support for SH1107 (issue 501)
158 | * Support for HX1230 (issue 469)
159 | * Bugfix for displays with display height not a multiple of 8 (issue 469)
160 | * FontUsage demo for full buffer mode (issue 490)
161 | * Added 1x2 (double height) draw procedures to U8x8 (issue 474)
162 | With this feature a 128x32 display can replace a 16x2 Char LCD.
163 | * New constructor for the Good Display 200x200 eInk (issue 454)
164 | * Update for the ST7920 device for more stable output (issue 487)
165 | * Double height (2x1) chars for U8x8 API (issue 474)
166 | * Excluded I2C for several ATMega uC which do not have HW I2C (issue 508)
167 | * Fixed UC1610 contrast command (issue 428)
168 | * Added WQY Chinese fonts at sizes 12, 13, 14, 15 and 16
169 | including gb2312 support (issue 455)
170 | * Added new full buffer demo for the Chinese fonts (Shennong.ino, issue #455)
171 | * Added siji icon font u8g2_font_siji_t_6x10 (issue 451)
172 |
173 |
--------------------------------------------------------------------------------
/libraries/U8g2/library.properties:
--------------------------------------------------------------------------------
1 | name=U8g2
2 | version=2.21.8
3 | author=oliver
4 | maintainer=oliver
5 | sentence=Monochrome LCD, OLED and eInk Library. Display controller: SSD1305, SSD1306, SSD1309, SSD1322, SSD1325, SSD1327, SSD1329, SSD1606, SSD1607, SH1106, T6963, RA8835, LC7981, PCD8544, PCF8812, UC1601, UC1604, UC1608, UC1610, UC1611, UC1701, ST7565, ST7567, ST7588, ST75256, NT7534, IST3020, ST7920, LD7032, KS0108, SED1520, SBN1661, IL3820, MAX7219. Interfaces: I2C, SPI, Parallel.
6 | paragraph=Monochrome LCD, OLED and eInk Library. Successor of U8glib. Supported display controller: SSD1305, SSD1306, SSD1309, SSD1322, SSD1325, SSD1327, SSD1329, SSD1606, SSD1607, SH1106, T6963, RA8835, LC7981, PCD8544, PCF8812, UC1601, UC1604, UC1608, UC1610, UC1611, UC1701, ST7565, ST7567, ST7588, ST75256, NT7534, IST3020, ST7920, LD7032, KS0108, SED1520, SBN1661, IL3820, MAX7219. Supported interfaces: I2C, SPI, Parallel. Features: UTF8, >700 fonts, U8x8 char output.
7 | category=Display
8 | url=https://github.com/olikraus/u8g2
9 | architectures=*
10 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8g2_bitmap.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8g2_bitmap.c
4 |
5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6 |
7 | Copyright (c) 2016, olikraus@gmail.com
8 | All rights reserved.
9 |
10 | Redistribution and use in source and binary forms, with or without modification,
11 | are permitted provided that the following conditions are met:
12 |
13 | * Redistributions of source code must retain the above copyright notice, this list
14 | of conditions and the following disclaimer.
15 |
16 | * Redistributions in binary form must reproduce the above copyright notice, this
17 | list of conditions and the following disclaimer in the documentation and/or other
18 | materials provided with the distribution.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
21 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 |
34 | */
35 |
36 | #include "u8g2.h"
37 |
38 |
39 | void u8g2_SetBitmapMode(u8g2_t *u8g2, uint8_t is_transparent) {
40 | u8g2->bitmap_transparency = is_transparent;
41 | }
42 |
43 | /*
44 | x,y Position on the display
45 | len Length of bitmap line in pixel. Note: This differs from u8glib which had a bytecount here.
46 | b Pointer to the bitmap line.
47 | Only draw pixels which are set.
48 | */
49 |
50 | void u8g2_DrawHorizontalBitmap(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, const uint8_t *b)
51 | {
52 | uint8_t mask;
53 | uint8_t color = u8g2->draw_color;
54 | uint8_t ncolor = (color == 0 ? 1 : 0);
55 |
56 | #ifdef U8G2_WITH_INTERSECTION
57 | if ( u8g2_IsIntersection(u8g2, x, y, x+len, y+1) == 0 )
58 | return;
59 | #endif /* U8G2_WITH_INTERSECTION */
60 |
61 | mask = 128;
62 | while(len > 0)
63 | {
64 | if ( *b & mask ) {
65 | u8g2->draw_color = color;
66 | u8g2_DrawHVLine(u8g2, x, y, 1, 0);
67 | } else if ( u8g2->bitmap_transparency == 0 ) {
68 | u8g2->draw_color = ncolor;
69 | u8g2_DrawHVLine(u8g2, x, y, 1, 0);
70 | }
71 |
72 | x++;
73 | mask >>= 1;
74 | if ( mask == 0 )
75 | {
76 | mask = 128;
77 | b++;
78 | }
79 | len--;
80 | }
81 | u8g2->draw_color = color;
82 | }
83 |
84 |
85 | /* u8glib compatible bitmap draw function */
86 | void u8g2_DrawBitmap(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t cnt, u8g2_uint_t h, const uint8_t *bitmap)
87 | {
88 | u8g2_uint_t w;
89 | w = cnt;
90 | w *= 8;
91 | #ifdef U8G2_WITH_INTERSECTION
92 | if ( u8g2_IsIntersection(u8g2, x, y, x+w, y+h) == 0 )
93 | return;
94 | #endif /* U8G2_WITH_INTERSECTION */
95 |
96 | while( h > 0 )
97 | {
98 | u8g2_DrawHorizontalBitmap(u8g2, x, y, w, bitmap);
99 | bitmap += cnt;
100 | y++;
101 | h--;
102 | }
103 | }
104 |
105 |
106 |
107 | void u8g2_DrawHXBM(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, const uint8_t *b)
108 | {
109 | uint8_t mask;
110 | uint8_t color = u8g2->draw_color;
111 | uint8_t ncolor = (color == 0 ? 1 : 0);
112 | #ifdef U8G2_WITH_INTERSECTION
113 | if ( u8g2_IsIntersection(u8g2, x, y, x+len, y+1) == 0 )
114 | return;
115 | #endif /* U8G2_WITH_INTERSECTION */
116 |
117 | mask = 1;
118 | while(len > 0) {
119 | if ( *b & mask ) {
120 | u8g2->draw_color = color;
121 | u8g2_DrawHVLine(u8g2, x, y, 1, 0);
122 | } else if ( u8g2->bitmap_transparency == 0 ) {
123 | u8g2->draw_color = ncolor;
124 | u8g2_DrawHVLine(u8g2, x, y, 1, 0);
125 | }
126 | x++;
127 | mask <<= 1;
128 | if ( mask == 0 )
129 | {
130 | mask = 1;
131 | b++;
132 | }
133 | len--;
134 | }
135 | u8g2->draw_color = color;
136 | }
137 |
138 |
139 | void u8g2_DrawXBM(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h, const uint8_t *bitmap)
140 | {
141 | u8g2_uint_t blen;
142 | blen = w;
143 | blen += 7;
144 | blen >>= 3;
145 | #ifdef U8G2_WITH_INTERSECTION
146 | if ( u8g2_IsIntersection(u8g2, x, y, x+w, y+h) == 0 )
147 | return;
148 | #endif /* U8G2_WITH_INTERSECTION */
149 |
150 | while( h > 0 )
151 | {
152 | u8g2_DrawHXBM(u8g2, x, y, w, bitmap);
153 | bitmap += blen;
154 | y++;
155 | h--;
156 | }
157 | }
158 |
159 |
160 |
161 |
162 |
163 |
164 | void u8g2_DrawHXBMP(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, const uint8_t *b)
165 | {
166 | uint8_t mask;
167 | uint8_t color = u8g2->draw_color;
168 | uint8_t ncolor = (color == 0 ? 1 : 0);
169 | #ifdef U8G2_WITH_INTERSECTION
170 | if ( u8g2_IsIntersection(u8g2, x, y, x+len, y+1) == 0 )
171 | return;
172 | #endif /* U8G2_WITH_INTERSECTION */
173 |
174 | mask = 1;
175 | while(len > 0)
176 | {
177 | if( u8x8_pgm_read(b) & mask ) {
178 | u8g2->draw_color = color;
179 | u8g2_DrawHVLine(u8g2, x, y, 1, 0);
180 | } else if( u8g2->bitmap_transparency == 0 ) {
181 | u8g2->draw_color = ncolor;
182 | u8g2_DrawHVLine(u8g2, x, y, 1, 0);
183 | }
184 |
185 | x++;
186 | mask <<= 1;
187 | if ( mask == 0 )
188 | {
189 | mask = 1;
190 | b++;
191 | }
192 | len--;
193 | }
194 | u8g2->draw_color = color;
195 | }
196 |
197 |
198 | void u8g2_DrawXBMP(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h, const uint8_t *bitmap)
199 | {
200 | u8g2_uint_t blen;
201 | blen = w;
202 | blen += 7;
203 | blen >>= 3;
204 | #ifdef U8G2_WITH_INTERSECTION
205 | if ( u8g2_IsIntersection(u8g2, x, y, x+w, y+h) == 0 )
206 | return;
207 | #endif /* U8G2_WITH_INTERSECTION */
208 |
209 | while( h > 0 )
210 | {
211 | u8g2_DrawHXBMP(u8g2, x, y, w, bitmap);
212 | bitmap += blen;
213 | y++;
214 | h--;
215 | }
216 | }
217 |
218 |
219 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8g2_box.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8g2_box.c
4 |
5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6 |
7 | Copyright (c) 2016, olikraus@gmail.com
8 | All rights reserved.
9 |
10 | Redistribution and use in source and binary forms, with or without modification,
11 | are permitted provided that the following conditions are met:
12 |
13 | * Redistributions of source code must retain the above copyright notice, this list
14 | of conditions and the following disclaimer.
15 |
16 | * Redistributions in binary form must reproduce the above copyright notice, this
17 | list of conditions and the following disclaimer in the documentation and/or other
18 | materials provided with the distribution.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
21 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 |
34 | */
35 |
36 | #include "u8g2.h"
37 |
38 | /*
39 | draw a filled box
40 | restriction: does not work for w = 0 or h = 0
41 | */
42 | void u8g2_DrawBox(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h)
43 | {
44 | #ifdef U8G2_WITH_INTERSECTION
45 | if ( u8g2_IsIntersection(u8g2, x, y, x+w, y+h) == 0 )
46 | return;
47 | #endif /* U8G2_WITH_INTERSECTION */
48 | while( h != 0 )
49 | {
50 | u8g2_DrawHVLine(u8g2, x, y, w, 0);
51 | y++;
52 | h--;
53 | }
54 | }
55 |
56 |
57 | /*
58 | draw a frame (empty box)
59 | restriction: does not work for w = 0 or h = 0
60 | ToDo:
61 | pixel in the corners are drawn twice. This could be optimized.
62 | */
63 | void u8g2_DrawFrame(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h)
64 | {
65 | u8g2_uint_t xtmp = x;
66 |
67 | #ifdef U8G2_WITH_INTERSECTION
68 | if ( u8g2_IsIntersection(u8g2, x, y, x+w, y+h) == 0 )
69 | return;
70 | #endif /* U8G2_WITH_INTERSECTION */
71 |
72 | u8g2_DrawHVLine(u8g2, x, y, w, 0);
73 | u8g2_DrawHVLine(u8g2, x, y, h, 1);
74 | x+=w;
75 | x--;
76 | u8g2_DrawHVLine(u8g2, x, y, h, 1);
77 | y+=h;
78 | y--;
79 | u8g2_DrawHVLine(u8g2, xtmp, y, w, 0);
80 | }
81 |
82 |
83 |
84 |
85 | void u8g2_DrawRBox(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h, u8g2_uint_t r)
86 | {
87 | u8g2_uint_t xl, yu;
88 | u8g2_uint_t yl, xr;
89 |
90 | #ifdef U8G2_WITH_INTERSECTION
91 | if ( u8g2_IsIntersection(u8g2, x, y, x+w, y+h) == 0 )
92 | return;
93 | #endif /* U8G2_WITH_INTERSECTION */
94 |
95 | xl = x;
96 | xl += r;
97 | yu = y;
98 | yu += r;
99 |
100 | xr = x;
101 | xr += w;
102 | xr -= r;
103 | xr -= 1;
104 |
105 | yl = y;
106 | yl += h;
107 | yl -= r;
108 | yl -= 1;
109 |
110 | u8g2_DrawDisc(u8g2, xl, yu, r, U8G2_DRAW_UPPER_LEFT);
111 | u8g2_DrawDisc(u8g2, xr, yu, r, U8G2_DRAW_UPPER_RIGHT);
112 | u8g2_DrawDisc(u8g2, xl, yl, r, U8G2_DRAW_LOWER_LEFT);
113 | u8g2_DrawDisc(u8g2, xr, yl, r, U8G2_DRAW_LOWER_RIGHT);
114 |
115 | {
116 | u8g2_uint_t ww, hh;
117 |
118 | ww = w;
119 | ww -= r;
120 | ww -= r;
121 | xl++;
122 | yu++;
123 |
124 | if ( ww >= 3 )
125 | {
126 | ww -= 2;
127 | u8g2_DrawBox(u8g2, xl, y, ww, r+1);
128 | u8g2_DrawBox(u8g2, xl, yl, ww, r+1);
129 | }
130 |
131 | hh = h;
132 | hh -= r;
133 | hh -= r;
134 | //h--;
135 | if ( hh >= 3 )
136 | {
137 | hh -= 2;
138 | u8g2_DrawBox(u8g2, x, yu, w, hh);
139 | }
140 | }
141 | }
142 |
143 |
144 | void u8g2_DrawRFrame(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w, u8g2_uint_t h, u8g2_uint_t r)
145 | {
146 | u8g2_uint_t xl, yu;
147 |
148 | #ifdef U8G2_WITH_INTERSECTION
149 | if ( u8g2_IsIntersection(u8g2, x, y, x+w, y+h) == 0 )
150 | return;
151 | #endif /* U8G2_WITH_INTERSECTION */
152 |
153 | xl = x;
154 | xl += r;
155 | yu = y;
156 | yu += r;
157 |
158 | {
159 | u8g2_uint_t yl, xr;
160 |
161 | xr = x;
162 | xr += w;
163 | xr -= r;
164 | xr -= 1;
165 |
166 | yl = y;
167 | yl += h;
168 | yl -= r;
169 | yl -= 1;
170 |
171 | u8g2_DrawCircle(u8g2, xl, yu, r, U8G2_DRAW_UPPER_LEFT);
172 | u8g2_DrawCircle(u8g2, xr, yu, r, U8G2_DRAW_UPPER_RIGHT);
173 | u8g2_DrawCircle(u8g2, xl, yl, r, U8G2_DRAW_LOWER_LEFT);
174 | u8g2_DrawCircle(u8g2, xr, yl, r, U8G2_DRAW_LOWER_RIGHT);
175 | }
176 |
177 | {
178 | u8g2_uint_t ww, hh;
179 |
180 | ww = w;
181 | ww -= r;
182 | ww -= r;
183 | hh = h;
184 | hh -= r;
185 | hh -= r;
186 |
187 | xl++;
188 | yu++;
189 |
190 | if ( ww >= 3 )
191 | {
192 | ww -= 2;
193 | h--;
194 | u8g2_DrawHLine(u8g2, xl, y, ww);
195 | u8g2_DrawHLine(u8g2, xl, y+h, ww);
196 | }
197 |
198 | if ( hh >= 3 )
199 | {
200 | hh -= 2;
201 | w--;
202 | u8g2_DrawVLine(u8g2, x, yu, hh);
203 | u8g2_DrawVLine(u8g2, x+w, yu, hh);
204 | }
205 | }
206 | }
207 |
208 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8g2_buffer.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8g2_buffer.c
4 |
5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6 |
7 | Copyright (c) 2016, olikraus@gmail.com
8 | All rights reserved.
9 |
10 | Redistribution and use in source and binary forms, with or without modification,
11 | are permitted provided that the following conditions are met:
12 |
13 | * Redistributions of source code must retain the above copyright notice, this list
14 | of conditions and the following disclaimer.
15 |
16 | * Redistributions in binary form must reproduce the above copyright notice, this
17 | list of conditions and the following disclaimer in the documentation and/or other
18 | materials provided with the distribution.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
21 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 |
34 | */
35 |
36 | #include "u8g2.h"
37 | #include
38 |
39 | /*============================================*/
40 | void u8g2_ClearBuffer(u8g2_t *u8g2)
41 | {
42 | size_t cnt;
43 | cnt = u8g2_GetU8x8(u8g2)->display_info->tile_width;
44 | cnt *= u8g2->tile_buf_height;
45 | cnt *= 8;
46 | memset(u8g2->tile_buf_ptr, 0, cnt);
47 | }
48 |
49 | /*============================================*/
50 |
51 | static void u8g2_send_tile_row(u8g2_t *u8g2, uint8_t src_tile_row, uint8_t dest_tile_row)
52 | {
53 | uint8_t *ptr;
54 | uint16_t offset;
55 | uint8_t w;
56 |
57 | w = u8g2_GetU8x8(u8g2)->display_info->tile_width;
58 | offset = src_tile_row;
59 | ptr = u8g2->tile_buf_ptr;
60 | offset *= w;
61 | offset *= 8;
62 | ptr += offset;
63 | u8x8_DrawTile(u8g2_GetU8x8(u8g2), 0, dest_tile_row, w, ptr);
64 | }
65 |
66 | /*
67 | write the buffer to the display RAM.
68 | For most displays, this will make the content visible to the user.
69 | Some displays (like the SSD1606) require a u8x8_RefreshDisplay()
70 | */
71 | static void u8g2_send_buffer(u8g2_t *u8g2) U8X8_NOINLINE;
72 | static void u8g2_send_buffer(u8g2_t *u8g2)
73 | {
74 | uint8_t src_row;
75 | uint8_t src_max;
76 | uint8_t dest_row;
77 | uint8_t dest_max;
78 |
79 | src_row = 0;
80 | src_max = u8g2->tile_buf_height;
81 | dest_row = u8g2->tile_curr_row;
82 | dest_max = u8g2_GetU8x8(u8g2)->display_info->tile_height;
83 |
84 | do
85 | {
86 | u8g2_send_tile_row(u8g2, src_row, dest_row);
87 | src_row++;
88 | dest_row++;
89 | } while( src_row < src_max && dest_row < dest_max );
90 | }
91 |
92 | /* same as u8g2_send_buffer but also send the DISPLAY_REFRESH message (used by SSD1606) */
93 | void u8g2_SendBuffer(u8g2_t *u8g2)
94 | {
95 | u8g2_send_buffer(u8g2);
96 | u8x8_RefreshDisplay( u8g2_GetU8x8(u8g2) );
97 | }
98 |
99 | /*============================================*/
100 | void u8g2_SetBufferCurrTileRow(u8g2_t *u8g2, uint8_t row)
101 | {
102 | u8g2->tile_curr_row = row;
103 | u8g2->cb->update(u8g2);
104 | }
105 |
106 | void u8g2_FirstPage(u8g2_t *u8g2)
107 | {
108 | if ( u8g2->is_auto_page_clear )
109 | {
110 | u8g2_ClearBuffer(u8g2);
111 | }
112 | u8g2_SetBufferCurrTileRow(u8g2, 0);
113 | }
114 |
115 | uint8_t u8g2_NextPage(u8g2_t *u8g2)
116 | {
117 | uint8_t row;
118 | u8g2_send_buffer(u8g2);
119 | row = u8g2->tile_curr_row;
120 | row += u8g2->tile_buf_height;
121 | if ( row >= u8g2_GetU8x8(u8g2)->display_info->tile_height )
122 | {
123 | u8x8_RefreshDisplay( u8g2_GetU8x8(u8g2) );
124 | return 0;
125 | }
126 | if ( u8g2->is_auto_page_clear )
127 | {
128 | u8g2_ClearBuffer(u8g2);
129 | }
130 | u8g2_SetBufferCurrTileRow(u8g2, row);
131 | return 1;
132 | }
133 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8g2_cleardisplay.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8g2_cleardisplay.c
4 |
5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6 |
7 | Copyright (c) 2016, 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 | #include "u8g2.h"
36 |
37 | /* clear screen buffer & display reliable for all u8g2 displays */
38 | /* this is, becasue we can not used the u8x8 function in all cases */
39 | void u8g2_ClearDisplay(u8g2_t *u8g2)
40 | {
41 | u8g2_FirstPage(u8g2);
42 | do {
43 | } while ( u8g2_NextPage(u8g2) );
44 | /*
45 | This function is usually called during startup (u8g2.begin()).
46 | However the user might want to use full buffer mode with clear and
47 | send commands.
48 | This will not work because the current tile row is modified by the picture
49 | loop above. To fix this, reset the tile row to 0, issue #370
50 | A workaround would be, that the user sets the current tile row to 0 manually.
51 | */
52 | u8g2_SetBufferCurrTileRow(u8g2, 0);
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8g2_fonts.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lyusupov/POST_S76G/9f51ff1edaf0adfae1e6cb3535eadefa8c421b45/libraries/U8g2/src/clib/u8g2_fonts.c
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8g2_hvline.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8g2_hvline.c
4 |
5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6 |
7 | Copyright (c) 2016, 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 | Calltree
36 | void u8g2_DrawHVLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
37 | u8g2->cb->draw_l90
38 | void u8g2_draw_hv_line_4dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
39 | void u8g2_draw_hv_line_2dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
40 | void u8g2_draw_pixel(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y)
41 |
42 | */
43 |
44 | #include "u8g2.h"
45 | #include
46 |
47 |
48 |
49 |
50 | #ifdef U8G2_WITH_CLIPPING
51 |
52 | /*
53 | Description:
54 | clip range from a (included) to b (excluded) agains c (included) to d (excluded)
55 | Assumptions:
56 | a <= b (violation is checked and handled correctly)
57 | c <= d (this is not checked)
58 | will return 0 if there is no intersection and if a > b
59 |
60 | optimized clipping: c is set to 0
61 | */
62 | //static uint8_t u8g2_clip_intersection(u8g2_uint_t *ap, u8g2_uint_t *bp, u8g2_uint_t c, u8g2_uint_t d)
63 | static uint8_t u8g2_clip_intersection(u8g2_uint_t *ap, u8g2_uint_t *bp, u8g2_uint_t d)
64 | {
65 | u8g2_uint_t a = *ap;
66 | u8g2_uint_t b = *bp;
67 |
68 | /* handle the a>b case correctly. If code and time is critical, this could */
69 | /* be removed completly (be aware about memory curruption for wrong */
70 | /* arguments) or return 0 for a>b (will lead to skipped lines for wrong */
71 | /* arguments) */
72 |
73 | /* removing the following if clause completly may lead to memory corruption of a>b */
74 | if ( a > b )
75 | {
76 | /* replacing this if with a simple "return 0;" will not handle the case with negative a */
77 | if ( a < d )
78 | {
79 | b = d;
80 | b--;
81 | *bp = b;
82 | }
83 | else
84 | {
85 | a = 0;
86 | *ap = a;
87 | }
88 | }
89 |
90 | /* from now on, the asumption a <= b is ok */
91 |
92 | if ( a >= d )
93 | return 0;
94 | if ( b <= 0 ) // was b <= c, could be replaced with b == 0
95 | return 0;
96 | //if ( a < c ) // never true with c == 0
97 | // *ap = c;
98 | if ( b > d )
99 | *bp = d;
100 |
101 | return 1;
102 | }
103 |
104 |
105 |
106 | /*
107 | x,y Upper left position of the line within the pixel buffer
108 | len length of the line in pixel, len must not be 0
109 | dir 0: horizontal line (left to right)
110 | 1: vertical line (top to bottom)
111 | This function first adjusts the y position to the local buffer. Then it
112 | will clip the line and call u8g2_draw_low_level_hv_line()
113 |
114 | */
115 | static void u8g2_draw_hv_line_2dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
116 | {
117 | u8g2_uint_t a;
118 | register u8g2_uint_t w, h;
119 |
120 | h = u8g2->pixel_buf_height; // this must be the real buffer height
121 | w = u8g2->pixel_buf_width; // this could be replaced by u8g2->u8x8.display_info->pixel_width
122 |
123 |
124 | if ( dir == 0 )
125 | {
126 | if ( y >= h )
127 | return;
128 | a = x;
129 | a += len;
130 | if ( u8g2_clip_intersection(&x, &a, w) == 0 )
131 | return;
132 | len = a;
133 | len -= x;
134 | }
135 | else
136 | {
137 | if ( x >= w )
138 | return;
139 | a = y;
140 | a += len;
141 | if ( u8g2_clip_intersection(&y, &a, h) == 0 )
142 | return;
143 | len = a;
144 | len -= y;
145 | }
146 |
147 | u8g2->ll_hvline(u8g2, x, y, len, dir);
148 | }
149 |
150 | #endif
151 |
152 | /*
153 | x,y Upper left position of the line (full screen coordinates)
154 | len length of the line in pixel, len must not be 0
155 | dir 0: horizontal line (left to right)
156 | 1: vertical line (top to bottom)
157 | 2: horizontal line (right to left)
158 | 3: vertical line (bottom to top)
159 |
160 | This function will remove directions 2 and 3. Instead 0 and 1 are used.
161 |
162 | */
163 | void u8g2_draw_hv_line_4dir(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
164 | {
165 | #ifdef U8G2_WITH_HVLINE_COUNT
166 | u8g2->hv_cnt++;
167 | #endif /* U8G2_WITH_HVLINE_COUNT */
168 |
169 | /* transform to pixel buffer coordinates */
170 | y -= u8g2->tile_curr_row*8;
171 |
172 | /* additional optimization for one pixel draw */
173 | /* requires about 60 bytes on the ATMega flash memory */
174 | /* 20% improvement for single pixel draw test in FPS.ino */
175 | #ifdef U8G2_WITH_ONE_PIXEL_OPTIMIZATION
176 | if ( len == 1 )
177 | {
178 | if ( x < u8g2->pixel_buf_width && y < u8g2->pixel_buf_height )
179 | u8g2->ll_hvline(u8g2, x, y, len, dir);
180 | return;
181 | }
182 | #endif
183 |
184 | if ( dir == 2 )
185 | {
186 | x -= len;
187 | x++;
188 | }
189 | else if ( dir == 3 )
190 | {
191 | y -= len;
192 | y++;
193 | }
194 | dir &= 1;
195 | #ifdef U8G2_WITH_CLIPPING
196 | u8g2_draw_hv_line_2dir(u8g2, x, y, len, dir);
197 | #else
198 | u8g2->ll_hvline(u8g2, x, y, len, dir);
199 | #endif
200 | }
201 |
202 | /*
203 | This is the toplevel function for the hv line draw procedures.
204 | This function should be called by the user.
205 | */
206 | void u8g2_DrawHVLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir)
207 | {
208 | /* Make a call to the callback function (e.g. u8g2_draw_l90_r0). */
209 | /* The callback may rotate the hv line */
210 | /* after rotation this will call u8g2_draw_hv_line_4dir() */
211 | if ( len != 0 )
212 | u8g2->cb->draw_l90(u8g2, x, y, len, dir);
213 | }
214 |
215 | void u8g2_DrawHLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len)
216 | {
217 | #ifdef U8G2_WITH_INTERSECTION
218 | if ( u8g2_IsIntersection(u8g2, x, y, x+len, y+1) == 0 )
219 | return;
220 | #endif /* U8G2_WITH_INTERSECTION */
221 | u8g2_DrawHVLine(u8g2, x, y, len, 0);
222 | }
223 |
224 | void u8g2_DrawVLine(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len)
225 | {
226 | #ifdef U8G2_WITH_INTERSECTION
227 | if ( u8g2_IsIntersection(u8g2, x, y, x+1, y+len) == 0 )
228 | return;
229 | #endif /* U8G2_WITH_INTERSECTION */
230 | u8g2_DrawHVLine(u8g2, x, y, len, 1);
231 | }
232 |
233 | void u8g2_DrawPixel(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y)
234 | {
235 | #ifdef U8G2_WITH_INTERSECTION
236 | if ( y < u8g2->user_y0 )
237 | return;
238 | if ( y >= u8g2->user_y1 )
239 | return;
240 | if ( x < u8g2->user_x0 )
241 | return;
242 | if ( x >= u8g2->user_x1 )
243 | return;
244 | #endif /* U8G2_WITH_INTERSECTION */
245 | u8g2_DrawHVLine(u8g2, x, y, 1, 0);
246 | }
247 |
248 | /*
249 | Assign the draw color for all drawing functions.
250 | color may be 0 or 1. The actual color is defined by the display.
251 | With color = 1 the drawing function will set the display memory to 1.
252 | For OLEDs this ususally means, that the pixel is enabled and the LED
253 | at the pixel is turned on.
254 | On an LCD it usually means that the LCD segment of the pixel is enabled,
255 | which absorbs the light.
256 | For eInk/ePaper it means black ink.
257 |
258 | 7 Jan 2017: Allow color value 2 for XOR operation.
259 |
260 | */
261 | void u8g2_SetDrawColor(u8g2_t *u8g2, uint8_t color)
262 | {
263 | u8g2->draw_color = color; /* u8g2_SetDrawColor: just assign the argument */
264 | if ( color >= 3 )
265 | u8g2->draw_color = 1; /* u8g2_SetDrawColor: make color as one if arg is invalid */
266 | }
267 |
268 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8g2_input_value.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8g2_input_value.c
4 |
5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6 |
7 | Copyright (c) 2016, olikraus@gmail.com
8 | All rights reserved.
9 |
10 | Redistribution and use in source and binary forms, with or without modification,
11 | are permitted provided that the following conditions are met:
12 |
13 | * Redistributions of source code must retain the above copyright notice, this list
14 | of conditions and the following disclaimer.
15 |
16 | * Redistributions in binary form must reproduce the above copyright notice, this
17 | list of conditions and the following disclaimer in the documentation and/or other
18 | materials provided with the distribution.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
21 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 |
34 | */
35 |
36 | #include "u8g2.h"
37 |
38 | /*
39 | return:
40 | 0: value is not changed (HOME/Break Button pressed)
41 | 1: value has been updated
42 | */
43 |
44 | uint8_t u8g2_UserInterfaceInputValue(u8g2_t *u8g2, const char *title, const char *pre, uint8_t *value, uint8_t lo, uint8_t hi, uint8_t digits, const char *post)
45 | {
46 | uint8_t line_height;
47 | uint8_t height;
48 | u8g2_uint_t pixel_height;
49 | u8g2_uint_t y, yy;
50 | u8g2_uint_t pixel_width;
51 | u8g2_uint_t x, xx;
52 |
53 | uint8_t local_value = *value;
54 | //uint8_t r; /* not used ??? */
55 | uint8_t event;
56 |
57 | /* only horizontal strings are supported, so force this here */
58 | u8g2_SetFontDirection(u8g2, 0);
59 |
60 | /* force baseline position */
61 | u8g2_SetFontPosBaseline(u8g2);
62 |
63 | /* calculate line height */
64 | line_height = u8g2_GetAscent(u8g2);
65 | line_height -= u8g2_GetDescent(u8g2);
66 |
67 |
68 | /* calculate overall height of the input value box */
69 | height = 1; /* value input line */
70 | height += u8x8_GetStringLineCnt(title);
71 |
72 | /* calculate the height in pixel */
73 | pixel_height = height;
74 | pixel_height *= line_height;
75 |
76 |
77 | /* calculate offset from top */
78 | y = 0;
79 | if ( pixel_height < u8g2_GetDisplayHeight(u8g2) )
80 | {
81 | y = u8g2_GetDisplayHeight(u8g2);
82 | y -= pixel_height;
83 | y /= 2;
84 | }
85 |
86 | /* calculate offset from left for the label */
87 | x = 0;
88 | pixel_width = u8g2_GetUTF8Width(u8g2, pre);
89 | pixel_width += u8g2_GetUTF8Width(u8g2, "0") * digits;
90 | pixel_width += u8g2_GetUTF8Width(u8g2, post);
91 | if ( pixel_width < u8g2_GetDisplayWidth(u8g2) )
92 | {
93 | x = u8g2_GetDisplayWidth(u8g2);
94 | x -= pixel_width;
95 | x /= 2;
96 | }
97 |
98 | /* event loop */
99 | for(;;)
100 | {
101 | u8g2_FirstPage(u8g2);
102 | do
103 | {
104 | /* render */
105 | yy = y;
106 | yy += u8g2_DrawUTF8Lines(u8g2, 0, yy, u8g2_GetDisplayWidth(u8g2), line_height, title);
107 | xx = x;
108 | xx += u8g2_DrawUTF8(u8g2, xx, yy, pre);
109 | xx += u8g2_DrawUTF8(u8g2, xx, yy, u8x8_u8toa(local_value, digits));
110 | u8g2_DrawUTF8(u8g2, xx, yy, post);
111 | } while( u8g2_NextPage(u8g2) );
112 |
113 | #ifdef U8G2_REF_MAN_PIC
114 | return 0;
115 | #endif
116 |
117 | for(;;)
118 | {
119 | event = u8x8_GetMenuEvent(u8g2_GetU8x8(u8g2));
120 | if ( event == U8X8_MSG_GPIO_MENU_SELECT )
121 | {
122 | *value = local_value;
123 | return 1;
124 | }
125 | else if ( event == U8X8_MSG_GPIO_MENU_HOME )
126 | {
127 | return 0;
128 | }
129 | else if ( event == U8X8_MSG_GPIO_MENU_NEXT || event == U8X8_MSG_GPIO_MENU_UP )
130 | {
131 | if ( local_value >= hi )
132 | local_value = lo;
133 | else
134 | local_value++;
135 | break;
136 | }
137 | else if ( event == U8X8_MSG_GPIO_MENU_PREV || event == U8X8_MSG_GPIO_MENU_DOWN )
138 | {
139 | if ( local_value <= lo )
140 | local_value = hi;
141 | else
142 | local_value--;
143 | break;
144 | }
145 | }
146 | }
147 |
148 | /* never reached */
149 | //return r;
150 | }
151 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8g2_intersection.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8g2_intersection.c
4 |
5 | Intersection calculation, code taken from u8g_clip.c
6 |
7 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
8 |
9 | Copyright (c) 2016, 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 "u8g2.h"
39 |
40 | #ifdef __GNUC__
41 | #define U8G2_ALWAYS_INLINE __inline__ __attribute__((always_inline))
42 | #else
43 | #define U8G2_ALWAYS_INLINE
44 | #endif
45 |
46 |
47 | #ifdef U8G2_WITH_INTERSECTION
48 |
49 | #ifdef OLD_VERSION_WITH_SYMETRIC_BOUNDARIES
50 |
51 | /*
52 | intersection assumptions:
53 | a1 <= a2 is always true
54 |
55 | minimized version
56 | ---1----0 1 b1 <= a2 && b1 > b2
57 | -----1--0 1 b2 >= a1 && b1 > b2
58 | ---1-1--- 1 b1 <= a2 && b2 >= a1
59 | */
60 |
61 |
62 | /*
63 | calculate the intersection between a0/a1 and v0/v1
64 | The intersection check returns one if the range of a0/a1 has an intersection with v0/v1.
65 | The intersection check includes the boundary values v1 and a1.
66 |
67 | The following asserts will succeed:
68 | assert( u8g2_is_intersection_decision_tree(4, 6, 7, 9) == 0 );
69 | assert( u8g2_is_intersection_decision_tree(4, 6, 6, 9) != 0 );
70 | assert( u8g2_is_intersection_decision_tree(6, 9, 4, 6) != 0 );
71 | assert( u8g2_is_intersection_decision_tree(7, 9, 4, 6) == 0 );
72 | */
73 |
74 | //static uint8_t U8G2_ALWAYS_INLINE u8g2_is_intersection_decision_tree(u8g_uint_t a0, u8g_uint_t a1, u8g_uint_t v0, u8g_uint_t v1)
75 | static uint8_t u8g2_is_intersection_decision_tree(u8g2_uint_t a0, u8g2_uint_t a1, u8g2_uint_t v0, u8g2_uint_t v1)
76 | {
77 | if ( v0 <= a1 )
78 | {
79 | if ( v1 >= a0 )
80 | {
81 | return 1;
82 | }
83 | else
84 | {
85 | if ( v0 > v1 )
86 | {
87 | return 1;
88 | }
89 | else
90 | {
91 | return 0;
92 | }
93 | }
94 | }
95 | else
96 | {
97 | if ( v1 >= a0 )
98 | {
99 | if ( v0 > v1 )
100 | {
101 | return 1;
102 | }
103 | else
104 | {
105 | return 0;
106 | }
107 | }
108 | else
109 | {
110 | return 0;
111 | }
112 | }
113 | }
114 |
115 | #endif /* OLD_VERSION_WITH_SYMETRIC_BOUNDARIES */
116 |
117 |
118 | /*
119 | version with asymetric boundaries.
120 | a1 and v1 are excluded
121 | v0 == v1 is not support end return 1
122 | */
123 | uint8_t u8g2_is_intersection_decision_tree(u8g2_uint_t a0, u8g2_uint_t a1, u8g2_uint_t v0, u8g2_uint_t v1)
124 | {
125 | if ( v0 < a1 ) // v0 <= a1
126 | {
127 | if ( v1 > a0 ) // v1 >= a0
128 | {
129 | return 1;
130 | }
131 | else
132 | {
133 | if ( v0 > v1 ) // v0 > v1
134 | {
135 | return 1;
136 | }
137 | else
138 | {
139 | return 0;
140 | }
141 | }
142 | }
143 | else
144 | {
145 | if ( v1 > a0 ) // v1 >= a0
146 | {
147 | if ( v0 > v1 ) // v0 > v1
148 | {
149 | return 1;
150 | }
151 | else
152 | {
153 | return 0;
154 | }
155 | }
156 | else
157 | {
158 | return 0;
159 | }
160 | }
161 | }
162 |
163 |
164 |
165 | /* upper limits are not included (asymetric boundaries) */
166 | uint8_t u8g2_IsIntersection(u8g2_t *u8g2, u8g2_uint_t x0, u8g2_uint_t y0, u8g2_uint_t x1, u8g2_uint_t y1)
167 | {
168 | if ( u8g2_is_intersection_decision_tree(u8g2->user_y0, u8g2->user_y1, y0, y1) == 0 )
169 | return 0;
170 |
171 | return u8g2_is_intersection_decision_tree(u8g2->user_x0, u8g2->user_x1, x0, x1);
172 | }
173 |
174 |
175 | #endif /* U8G2_WITH_INTERSECTION */
176 |
177 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8g2_kerning.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8g2_kerning.c
4 |
5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6 |
7 | Copyright (c) 2016, olikraus@gmail.com
8 | All rights reserved.
9 |
10 | Redistribution and use in source and binary forms, with or without modification,
11 | are permitted provided that the following conditions are met:
12 |
13 | * Redistributions of source code must retain the above copyright notice, this list
14 | of conditions and the following disclaimer.
15 |
16 | * Redistributions in binary form must reproduce the above copyright notice, this
17 | list of conditions and the following disclaimer in the documentation and/or other
18 | materials provided with the distribution.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
21 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 |
34 | */
35 |
36 | #include "u8g2.h"
37 |
38 | /* this function is used as "u8g2_get_kerning_cb" */
39 | /*
40 | uint8_t u8g2_GetNullKerning(u8g2_t *u8g2, uint16_t e1, uint16_t e2)
41 | {
42 | return 0;
43 | }
44 | */
45 |
46 | /* this function is used as "u8g2_get_kerning_cb" */
47 | uint8_t u8g2_GetKerning(U8X8_UNUSED u8g2_t *u8g2, u8g2_kerning_t *kerning, uint16_t e1, uint16_t e2)
48 | {
49 | uint16_t i1, i2, cnt, end;
50 | if ( kerning == NULL )
51 | return 0;
52 |
53 | /* search for the encoding in the first table */
54 | cnt = kerning->first_table_cnt;
55 | cnt--; /* ignore the last element of the table, which is 0x0ffff */
56 | for( i1 = 0; i1 < cnt; i1++ )
57 | {
58 | if ( kerning->first_encoding_table[i1] == e1 )
59 | break;
60 | }
61 | if ( i1 >= cnt )
62 | return 0; /* e1 not part of the kerning table, return 0 */
63 |
64 | /* get the upper index for i2 */
65 | end = kerning->index_to_second_table[i1+1];
66 | for( i2 = kerning->index_to_second_table[i1]; i2 < end; i2++ )
67 | {
68 | if ( kerning->second_encoding_table[i2] == e2 )
69 | break;
70 | }
71 |
72 | if ( i2 >= end )
73 | return 0; /* e2 not part of any pair with e1, return 0 */
74 |
75 | return kerning->kerning_values[i2];
76 | }
77 |
78 | uint8_t u8g2_GetKerningByTable(U8X8_UNUSED u8g2_t *u8g2, const uint16_t *kt, uint16_t e1, uint16_t e2)
79 | {
80 | uint16_t i;
81 | i = 0;
82 | if ( kt == NULL )
83 | return 0;
84 | for(;;)
85 | {
86 | if ( kt[i] == 0x0ffff )
87 | break;
88 | if ( kt[i] == e1 && kt[i+1] == e2 )
89 | return kt[i+2];
90 | i+=3;
91 | }
92 | return 0;
93 | }
94 |
95 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8g2_line.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8g2_box.c
4 |
5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6 |
7 | Copyright (c) 2016, olikraus@gmail.com
8 | All rights reserved.
9 |
10 | Redistribution and use in source and binary forms, with or without modification,
11 | are permitted provided that the following conditions are met:
12 |
13 | * Redistributions of source code must retain the above copyright notice, this list
14 | of conditions and the following disclaimer.
15 |
16 | * Redistributions in binary form must reproduce the above copyright notice, this
17 | list of conditions and the following disclaimer in the documentation and/or other
18 | materials provided with the distribution.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
21 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 |
34 | */
35 |
36 | #include "u8g2.h"
37 |
38 |
39 | void u8g2_DrawLine(u8g2_t *u8g2, u8g2_uint_t x1, u8g2_uint_t y1, u8g2_uint_t x2, u8g2_uint_t y2)
40 | {
41 | u8g2_uint_t tmp;
42 | u8g2_uint_t x,y;
43 | u8g2_uint_t dx, dy;
44 | u8g2_int_t err;
45 | u8g2_int_t ystep;
46 |
47 | uint8_t swapxy = 0;
48 |
49 | /* no intersection check at the moment, should be added... */
50 |
51 | if ( x1 > x2 ) dx = x1-x2; else dx = x2-x1;
52 | if ( y1 > y2 ) dy = y1-y2; else dy = y2-y1;
53 |
54 | if ( dy > dx )
55 | {
56 | swapxy = 1;
57 | tmp = dx; dx =dy; dy = tmp;
58 | tmp = x1; x1 =y1; y1 = tmp;
59 | tmp = x2; x2 =y2; y2 = tmp;
60 | }
61 | if ( x1 > x2 )
62 | {
63 | tmp = x1; x1 =x2; x2 = tmp;
64 | tmp = y1; y1 =y2; y2 = tmp;
65 | }
66 | err = dx >> 1;
67 | if ( y2 > y1 ) ystep = 1; else ystep = -1;
68 | y = y1;
69 |
70 | #ifndef U8G2_16BIT
71 | if ( x2 == 255 )
72 | x2--;
73 | #else
74 | if ( x2 == 0xffff )
75 | x2--;
76 | #endif
77 |
78 | for( x = x1; x <= x2; x++ )
79 | {
80 | if ( swapxy == 0 )
81 | u8g2_DrawPixel(u8g2, x, y);
82 | else
83 | u8g2_DrawPixel(u8g2, y, x);
84 | err -= (uint8_t)dy;
85 | if ( err < 0 )
86 | {
87 | y += (u8g2_uint_t)ystep;
88 | err += (u8g2_uint_t)dx;
89 | }
90 | }
91 | }
92 |
93 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8g2_message.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8g2_message.c
4 |
5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6 |
7 | Copyright (c) 2016, olikraus@gmail.com
8 | All rights reserved.
9 |
10 | Redistribution and use in source and binary forms, with or without modification,
11 | are permitted provided that the following conditions are met:
12 |
13 | * Redistributions of source code must retain the above copyright notice, this list
14 | of conditions and the following disclaimer.
15 |
16 | * Redistributions in binary form must reproduce the above copyright notice, this
17 | list of conditions and the following disclaimer in the documentation and/or other
18 | materials provided with the distribution.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
21 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 |
34 | */
35 |
36 | #include "u8g2.h"
37 |
38 | #define SPACE_BETWEEN_BUTTONS_IN_PIXEL 6
39 | #define SPACE_BETWEEN_TEXT_AND_BUTTONS_IN_PIXEL 3
40 |
41 | uint8_t u8g2_draw_button_line(u8g2_t *u8g2, u8g2_uint_t y, u8g2_uint_t w, uint8_t cursor, const char *s)
42 | {
43 | u8g2_uint_t button_line_width;
44 |
45 | uint8_t i;
46 | uint8_t cnt;
47 | uint8_t is_invert;
48 |
49 | u8g2_uint_t d;
50 | u8g2_uint_t x;
51 |
52 | cnt = u8x8_GetStringLineCnt(s);
53 |
54 |
55 | /* calculate the width of the button line */
56 | button_line_width = 0;
57 | for( i = 0; i < cnt; i++ )
58 | {
59 | button_line_width += u8g2_GetUTF8Width(u8g2, u8x8_GetStringLineStart(i, s));
60 | }
61 | button_line_width += (cnt-1)*SPACE_BETWEEN_BUTTONS_IN_PIXEL; /* add some space between the buttons */
62 |
63 | /* calculate the left offset */
64 | d = 0;
65 | if ( button_line_width < w )
66 | {
67 | d = w;
68 | d -= button_line_width;
69 | d /= 2;
70 | }
71 |
72 | /* draw the buttons */
73 | x = d;
74 | for( i = 0; i < cnt; i++ )
75 | {
76 | is_invert = 0;
77 | if ( i == cursor )
78 | is_invert = 1;
79 |
80 | u8g2_DrawUTF8Line(u8g2, x, y, 0, u8x8_GetStringLineStart(i, s), 1, is_invert);
81 | x += u8g2_GetUTF8Width(u8g2, u8x8_GetStringLineStart(i, s));
82 | x += SPACE_BETWEEN_BUTTONS_IN_PIXEL;
83 | }
84 |
85 | /* return the number of buttons */
86 | return cnt;
87 | }
88 |
89 | /*
90 | title1: Multiple lines,separated by '\n'
91 | title2: A single line/string which is terminated by '\0' or '\n' . "title2" accepts the return value from u8x8_GetStringLineStart()
92 | title3: Multiple lines,separated by '\n'
93 | buttons: one more more buttons separated by '\n' and terminated with '\0'
94 | side effects:
95 | u8g2_SetFontDirection(u8g2, 0);
96 | u8g2_SetFontPosBaseline(u8g2);
97 | */
98 |
99 | uint8_t u8g2_UserInterfaceMessage(u8g2_t *u8g2, const char *title1, const char *title2, const char *title3, const char *buttons)
100 | {
101 | uint8_t height;
102 | uint8_t line_height;
103 | u8g2_uint_t pixel_height;
104 | u8g2_uint_t y, yy;
105 |
106 | uint8_t cursor = 0;
107 | uint8_t button_cnt;
108 | uint8_t event;
109 |
110 | /* only horizontal strings are supported, so force this here */
111 | u8g2_SetFontDirection(u8g2, 0);
112 |
113 | /* force baseline position */
114 | u8g2_SetFontPosBaseline(u8g2);
115 |
116 |
117 | /* calculate line height */
118 | line_height = u8g2_GetAscent(u8g2);
119 | line_height -= u8g2_GetDescent(u8g2);
120 |
121 | /* calculate overall height of the message box in lines*/
122 | height = 1; /* button line */
123 | height += u8x8_GetStringLineCnt(title1);
124 | if ( title2 != NULL )
125 | height++;
126 | height += u8x8_GetStringLineCnt(title3);
127 |
128 | /* calculate the height in pixel */
129 | pixel_height = height;
130 | pixel_height *= line_height;
131 |
132 | /* ... and add the space between the text and the buttons */
133 | pixel_height +=SPACE_BETWEEN_TEXT_AND_BUTTONS_IN_PIXEL;
134 |
135 | /* calculate offset from top */
136 | y = 0;
137 | if ( pixel_height < u8g2_GetDisplayHeight(u8g2) )
138 | {
139 | y = u8g2_GetDisplayHeight(u8g2);
140 | y -= pixel_height;
141 | y /= 2;
142 | }
143 | y += u8g2_GetAscent(u8g2);
144 |
145 |
146 | for(;;)
147 | {
148 | u8g2_FirstPage(u8g2);
149 | do
150 | {
151 | yy = y;
152 | /* draw message box */
153 |
154 | yy += u8g2_DrawUTF8Lines(u8g2, 0, yy, u8g2_GetDisplayWidth(u8g2), line_height, title1);
155 | if ( title2 != NULL )
156 | {
157 | u8g2_DrawUTF8Line(u8g2, 0, yy, u8g2_GetDisplayWidth(u8g2), title2, 0, 0);
158 | yy+=line_height;
159 | }
160 | yy += u8g2_DrawUTF8Lines(u8g2, 0, yy, u8g2_GetDisplayWidth(u8g2), line_height, title3);
161 | yy += SPACE_BETWEEN_TEXT_AND_BUTTONS_IN_PIXEL;
162 |
163 | button_cnt = u8g2_draw_button_line(u8g2, yy, u8g2_GetDisplayWidth(u8g2), cursor, buttons);
164 |
165 | } while( u8g2_NextPage(u8g2) );
166 |
167 | #ifdef U8G2_REF_MAN_PIC
168 | return 0;
169 | #endif
170 |
171 | for(;;)
172 | {
173 | event = u8x8_GetMenuEvent(u8g2_GetU8x8(u8g2));
174 | if ( event == U8X8_MSG_GPIO_MENU_SELECT )
175 | return cursor+1;
176 | else if ( event == U8X8_MSG_GPIO_MENU_HOME )
177 | return 0;
178 | else if ( event == U8X8_MSG_GPIO_MENU_NEXT || event == U8X8_MSG_GPIO_MENU_DOWN )
179 | {
180 | cursor++;
181 | if ( cursor >= button_cnt )
182 | cursor = 0;
183 | break;
184 | }
185 | else if ( event == U8X8_MSG_GPIO_MENU_PREV || event == U8X8_MSG_GPIO_MENU_UP )
186 | {
187 | if ( cursor == 0 )
188 | cursor = button_cnt;
189 | cursor--;
190 | break;
191 | }
192 | }
193 | }
194 | /* never reached */
195 | //return 0;
196 | }
197 |
198 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8x8_d_a2printer.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8x8_d_a2printer.c
4 |
5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6 |
7 | Copyright (c) 2016, 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 | Use DC2 bitmap command of the A2 Micro panel termal printer
36 | double stroke
37 |
38 |
39 | */
40 |
41 |
42 | #include "u8x8.h"
43 |
44 | #define LINE_MIN_DELAY_MS 15
45 | /* higher values improve quality */
46 | /* however if the value is too high (>=5) then form feed does not work any more */
47 | #define LINE_EXTRA_8PIXEL_DELAY_MS 3
48 | /* this must be a power of two and between 1 and 8 */
49 | /* best quality only with 1 */
50 | #define NO_OF_LINES_TO_SEND_WITHOUT_DELAY 1
51 |
52 | /* calculates the delay, based on the number of black pixel */
53 | /* actually only "none-zero" bytes are calculated which is, of course not so accurate, but should be good enough */
54 | uint16_t get_delay_in_milliseconds(uint8_t cnt, uint8_t *data)
55 | {
56 | uint8_t i;
57 | uint16_t time = LINE_MIN_DELAY_MS;
58 | for ( i = 0; i < cnt; i++ )
59 | if ( data[i] != 0 )
60 | time += LINE_EXTRA_8PIXEL_DELAY_MS;
61 | return time;
62 | }
63 |
64 | uint8_t u8x8_d_a2printer_common(u8x8_t *u8x8, uint8_t msg, U8X8_UNUSED uint8_t arg_int, void *arg_ptr)
65 | {
66 | uint8_t c, i, j;
67 | uint8_t *ptr;
68 | uint16_t delay_in_milliseconds;
69 | switch(msg)
70 | {
71 | /* U8X8_MSG_DISPLAY_SETUP_MEMORY is handled by the calling function */
72 | /*
73 | case U8X8_MSG_DISPLAY_SETUP_MEMORY:
74 | break;
75 | */
76 | case U8X8_MSG_DISPLAY_INIT:
77 | u8x8_d_helper_display_init(u8x8);
78 | // no setup required
79 | // u8x8_cad_SendSequence(u8x8, u8x8_d_a2printer_init_seq);
80 | break;
81 | case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
82 | // no powersave
83 | break;
84 | case U8X8_MSG_DISPLAY_DRAW_TILE:
85 | u8x8_cad_StartTransfer(u8x8);
86 |
87 | u8x8_cad_SendCmd(u8x8, 27); /* ESC */
88 | u8x8_cad_SendCmd(u8x8, 55 ); /* parameter command */
89 | /* increasing the "max printing dots" requires a good power supply, but LINE_EXTRA_8PIXEL_DELAY_MS could be reduced then */
90 | u8x8_cad_SendCmd(u8x8, 0); /* Max printing dots,Unit(8dots),Default:7(64 dots) 8*(x+1) ... lower values improve, probably my current supply is not sufficient */
91 | u8x8_cad_SendCmd(u8x8, 200); /* 3-255 Heating time,Unit(10us),Default:80(800us) */
92 | u8x8_cad_SendCmd(u8x8, 2); /* 0-255 Heating interval,Unit(10us),Default:2(20us) ... does not have much influence */
93 |
94 | //c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */
95 | c = u8x8->display_info->tile_width;
96 | ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; /* data ptr to the tiles */
97 |
98 | u8x8_cad_SendCmd(u8x8, 18); /* DC2 */
99 | u8x8_cad_SendCmd(u8x8, 42 ); /* * */
100 | u8x8_cad_SendCmd(u8x8, 8 ); /* height */
101 | u8x8_cad_SendCmd(u8x8, c ); /* c, u8x8->display_info->tile_width */
102 |
103 | for( j = 0; j < 8 / NO_OF_LINES_TO_SEND_WITHOUT_DELAY; j ++ )
104 | {
105 |
106 | delay_in_milliseconds = 0;
107 | for( i = 0; i < NO_OF_LINES_TO_SEND_WITHOUT_DELAY; i++ )
108 | {
109 | u8x8_cad_SendData(u8x8, c, ptr); /* c, note: SendData can not handle more than 255 bytes, send one line of data */
110 | delay_in_milliseconds += get_delay_in_milliseconds(c, ptr);
111 | ptr += c;
112 | }
113 |
114 | while( delay_in_milliseconds > 200 )
115 | {
116 | u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_MILLI, 200, NULL);
117 | delay_in_milliseconds -= 200;
118 | }
119 | u8x8->gpio_and_delay_cb(u8x8, U8X8_MSG_DELAY_MILLI, delay_in_milliseconds, NULL);
120 | }
121 |
122 | /* set parameters back to their default values */
123 | u8x8_cad_SendCmd(u8x8, 27); /* ESC */
124 | u8x8_cad_SendCmd(u8x8, 55 ); /* parameter command */
125 | u8x8_cad_SendCmd(u8x8, 7); /* Max printing dots,Unit(8dots),Default:7(64 dots) 8*(x+1)*/
126 | u8x8_cad_SendCmd(u8x8, 80); /* 3-255 Heating time,Unit(10us),Default:80(800us) */
127 | u8x8_cad_SendCmd(u8x8, 2); /* 0-255 Heating interval,Unit(10us),Default:2(20us)*/
128 |
129 | u8x8_cad_EndTransfer(u8x8);
130 |
131 | break;
132 | default:
133 | return 0;
134 | }
135 | return 1;
136 | }
137 |
138 |
139 | static const u8x8_display_info_t u8x8_a2printer_384x240_display_info =
140 | {
141 | /* most of the settings are not required, because this is a serial RS232 printer */
142 |
143 | /* chip_enable_level = */ 1,
144 | /* chip_disable_level = */ 0,
145 |
146 | /* post_chip_enable_wait_ns = */ 5,
147 | /* pre_chip_disable_wait_ns = */ 5,
148 | /* reset_pulse_width_ms = */ 1,
149 | /* post_reset_wait_ms = */ 6,
150 | /* sda_setup_time_ns = */ 20,
151 | /* sck_pulse_width_ns = */ 140,
152 | /* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
153 | /* spi_mode = */ 0, /* old: sck_takeover_edge, new: active high (bit 1), rising edge (bit 0) */
154 | /* i2c_bus_clock_100kHz = */ 4,
155 | /* data_setup_time_ns = */ 30,
156 | /* write_pulse_width_ns = */ 40,
157 | /* tile_width = */ 48,
158 | /* tile_hight = */ 30,
159 | /* default_x_offset = */ 0,
160 | /* flipmode_x_offset = */ 0,
161 | /* pixel_width = */ 384,
162 | /* pixel_height = */ 240
163 | };
164 |
165 | uint8_t u8x8_d_a2printer_384x240(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
166 | {
167 | switch(msg)
168 | {
169 | case U8X8_MSG_DISPLAY_SETUP_MEMORY:
170 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_a2printer_384x240_display_info);
171 | break;
172 | default:
173 | return u8x8_d_a2printer_common(u8x8, msg, arg_int, arg_ptr);
174 | }
175 | return 1;
176 | }
177 |
178 |
179 |
180 |
181 |
182 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8x8_d_ist3020.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8x8_d_ist3020.c
4 |
5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6 |
7 | Copyright (c) 2017, olikraus@gmail.com
8 | All rights reserved.
9 |
10 | Redistribution and use in source and binary forms, with or without modification,
11 | are permitted provided that the following conditions are met:
12 |
13 | * Redistributions of source code must retain the above copyright notice, this list
14 | of conditions and the following disclaimer.
15 |
16 | * Redistributions in binary form must reproduce the above copyright notice, this
17 | list of conditions and the following disclaimer in the documentation and/or other
18 | materials provided with the distribution.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
21 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 |
34 |
35 | */
36 | #include "u8x8.h"
37 |
38 |
39 |
40 |
41 | static const uint8_t u8x8_d_ist3020_erc19264_powersave0_seq[] = {
42 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
43 | U8X8_C(0x0a4), /* all pixel off, issue 142 */
44 | U8X8_C(0x0af), /* display on */
45 | U8X8_END_TRANSFER(), /* disable chip */
46 | U8X8_END() /* end of sequence */
47 | };
48 |
49 | static const uint8_t u8x8_d_ist3020_erc19264_powersave1_seq[] = {
50 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
51 | U8X8_C(0x0ae), /* display off */
52 | U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */
53 | U8X8_END_TRANSFER(), /* disable chip */
54 | U8X8_END() /* end of sequence */
55 | };
56 |
57 | static const uint8_t u8x8_d_ist3020_erc19264_flip0_seq[] = {
58 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
59 | U8X8_C(0x0a0), /* segment remap a0/a1*/
60 | U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
61 | U8X8_END_TRANSFER(), /* disable chip */
62 | U8X8_END() /* end of sequence */
63 | };
64 |
65 | static const uint8_t u8x8_d_ist3020_erc19264_flip1_seq[] = {
66 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
67 | U8X8_C(0x0a1), /* segment remap a0/a1*/
68 | U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
69 | U8X8_END_TRANSFER(), /* disable chip */
70 | U8X8_END() /* end of sequence */
71 | };
72 |
73 |
74 | static const u8x8_display_info_t u8x8_ist3020_erc19264_display_info =
75 | {
76 | /* chip_enable_level = */ 0,
77 | /* chip_disable_level = */ 1,
78 |
79 | /* post_chip_enable_wait_ns = */ 150, /* IST3020 datasheet, page 56 */
80 | /* pre_chip_disable_wait_ns = */ 150, /* IST3020 datasheet, page 56 */
81 | /* reset_pulse_width_ms = */ 1,
82 | /* post_reset_wait_ms = */ 1,
83 | /* sda_setup_time_ns = */ 100, /* IST3020 datasheet, page 56 */
84 | /* sck_pulse_width_ns = */ 100, /* IST3020 datasheet, page 56 */
85 | /* sck_clock_hz = */ 4000000UL, /* */
86 | /* spi_mode = */ 0, /* active high, rising edge */
87 | /* i2c_bus_clock_100kHz = */ 4,
88 | /* data_setup_time_ns = */ 40, /* IST3020 datasheet, page 54 */
89 | /* write_pulse_width_ns = */ 60, /* IST3020 datasheet, page 54 */
90 | /* tile_width = */ 24, /* width of 24*8=192 pixel */
91 | /* tile_hight = */ 8,
92 | /* default_x_offset = */ 0,
93 | /* flipmode_x_offset = */ 64,
94 | /* pixel_width = */ 192,
95 | /* pixel_height = */ 64
96 | };
97 |
98 | static const uint8_t u8x8_d_ist3020_erc19264_init_seq[] = {
99 |
100 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
101 |
102 | U8X8_C(0x0e2), /* soft reset */
103 | U8X8_C(0x0ab), /* build in osc on, used in ER code, but not mentioned in data sheet */
104 | U8X8_C(0x0ae), /* display off */
105 |
106 | U8X8_C(0x040), /* set display start line to 0 */
107 |
108 | U8X8_C(0x0a0), /* ADC set to reverse */
109 | U8X8_C(0x0c8), /* common output mode */
110 | // Flipmode
111 | //U8X8_C(0x0a0), /* ADC set to reverse */
112 | //U8X8_C(0x0c8), /* common output mode */
113 |
114 | U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */
115 | U8X8_C(0x0a3), /* FIX: LCD bias 1/7, old value was 1/9 (0x0a2) */
116 |
117 | U8X8_C(0x028|4), /* all power control circuits on */
118 | U8X8_DLY(50),
119 | U8X8_C(0x028|6), /* all power control circuits on */
120 | U8X8_DLY(50),
121 | U8X8_C(0x028|7), /* all power control circuits on */
122 | U8X8_DLY(50),
123 |
124 | U8X8_C(0x020), /* v0 voltage resistor ratio */
125 | U8X8_CA(0x081, 0x019), /* set contrast, contrast value (from ER code: 45) */
126 |
127 | U8X8_C(0x0ae), /* display off */
128 | U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */
129 |
130 | U8X8_END_TRANSFER(), /* disable chip */
131 | U8X8_END() /* end of sequence */
132 | };
133 |
134 | uint8_t u8x8_d_ist3020_erc19264(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
135 | {
136 | uint8_t x, c;
137 | uint8_t *ptr;
138 | switch(msg)
139 | {
140 | case U8X8_MSG_DISPLAY_SETUP_MEMORY:
141 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ist3020_erc19264_display_info);
142 | break;
143 | case U8X8_MSG_DISPLAY_INIT:
144 | u8x8_d_helper_display_init(u8x8);
145 | u8x8_cad_SendSequence(u8x8, u8x8_d_ist3020_erc19264_init_seq);
146 | break;
147 | case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
148 | if ( arg_int == 0 )
149 | u8x8_cad_SendSequence(u8x8, u8x8_d_ist3020_erc19264_powersave0_seq);
150 | else
151 | u8x8_cad_SendSequence(u8x8, u8x8_d_ist3020_erc19264_powersave1_seq);
152 | break;
153 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
154 | if ( arg_int == 0 )
155 | {
156 | u8x8_cad_SendSequence(u8x8, u8x8_d_ist3020_erc19264_flip0_seq);
157 | u8x8->x_offset = u8x8->display_info->default_x_offset;
158 | }
159 | else
160 | {
161 | u8x8_cad_SendSequence(u8x8, u8x8_d_ist3020_erc19264_flip1_seq);
162 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
163 | }
164 | break;
165 | #ifdef U8X8_WITH_SET_CONTRAST
166 | case U8X8_MSG_DISPLAY_SET_CONTRAST:
167 | u8x8_cad_StartTransfer(u8x8);
168 | u8x8_cad_SendCmd(u8x8, 0x081 );
169 | u8x8_cad_SendArg(u8x8, arg_int >> 2 ); /* st7567 has range from 0 to 63 */
170 | u8x8_cad_EndTransfer(u8x8);
171 | break;
172 | #endif
173 | case U8X8_MSG_DISPLAY_DRAW_TILE:
174 | u8x8_cad_StartTransfer(u8x8);
175 |
176 | x = ((u8x8_tile_t *)arg_ptr)->x_pos;
177 | x *= 8;
178 | x += u8x8->x_offset;
179 | u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
180 | u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
181 | u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
182 |
183 | c = ((u8x8_tile_t *)arg_ptr)->cnt;
184 | c *= 8;
185 | ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
186 | do
187 | {
188 | u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
189 | arg_int--;
190 | } while( arg_int > 0 );
191 |
192 | u8x8_cad_EndTransfer(u8x8);
193 | break;
194 | default:
195 | return 0;
196 | }
197 | return 1;
198 | }
199 |
200 |
201 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8x8_d_ld7032_60x32.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8x8_d_ld7032_60x32.c
4 | Note: Flip Mode is NOT supported
5 |
6 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
7 |
8 | Copyright (c) 2016, olikraus@gmail.com
9 | All rights reserved.
10 |
11 | Redistribution and use in source and binary forms, with or without modification,
12 | are permitted provided that the following conditions are met:
13 |
14 | * Redistributions of source code must retain the above copyright notice, this list
15 | of conditions and the following disclaimer.
16 |
17 | * Redistributions in binary form must reproduce the above copyright notice, this
18 | list of conditions and the following disclaimer in the documentation and/or other
19 | materials provided with the distribution.
20 |
21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
22 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
23 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
31 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
33 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 |
35 | */
36 |
37 |
38 | #include "u8x8.h"
39 |
40 |
41 | /* testboard U8GLIB_LD7032_60x32 u8g(11, 12, 9, 10, 8); // SPI Com: SCK = 11, MOSI = 12, CS = 9, A0 = 10, RST = 8 (SW SPI Nano Board) */
42 | /* http://www.seeedstudio.com/document/pdf/0.5OLED%20SPEC.pdf */
43 | static const uint8_t u8x8_d_ld7032_60x32_init_seq[] = {
44 |
45 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
46 |
47 | //U8X8_CA(0x002, 0x001), /* Dot Matrix Display ON */
48 | U8X8_CA(0x014, 0x000), /* Stand-by OFF */
49 | U8X8_CA(0x01a, 0x004), /* Dot Matrix Frame Rate, special value for this OLED from manual*/
50 | U8X8_CA(0x01d, 0x000), /* Graphics Memory Writing Direction: reset default (right down, horizontal) */
51 | U8X8_CA(0x009, 0x000), /* Display Direction: reset default (x,y: min --> max) */
52 | U8X8_CAA(0x030, 0x000, 0x03b), /* Display Size X, Column Start - End*/
53 | U8X8_CAA(0x032, 0x000, 0x01f), /* Display Size Y, Row Start - End*/
54 | U8X8_CA(0x010, 0x000), /* Peak Pulse Width Set: 0 SCLK */
55 | U8X8_CA(0x016, 0x000), /* Peak Pulse Delay Set: 0 SCLK */
56 | U8X8_CA(0x012, 0x040), /* Dot Matrix Current Level Set: 0x050 * 1 uA = 80 uA */
57 | U8X8_CA(0x018, 0x003), /* Pre-Charge Pulse Width: 3 SCLK */
58 | U8X8_CA(0x044, 0x002), /* Pre-Charge Mode: Every Time */
59 | U8X8_CA(0x048, 0x003), /* Row overlap timing: Pre-Charge + Peak Delay + Peak boot Timing */
60 | U8X8_CA(0x03f, 0x011), /* VCC_R_SEL: ??? */
61 | U8X8_CA(0x03d, 0x000), /* VSS selection: 2.8V */
62 | //U8X8_CA(0x002, 0x001), /* Dot Matrix Display ON */
63 |
64 |
65 | U8X8_END_TRANSFER(), /* disable chip */
66 | U8X8_END() /* end of sequence */
67 | };
68 |
69 | static const uint8_t u8x8_d_ld7032_60x32_powersave0_seq[] = {
70 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
71 | U8X8_CA(0x002, 0x001), /* Dot Matrix Display ON */
72 | U8X8_END_TRANSFER(), /* disable chip */
73 | U8X8_END() /* end of sequence */
74 | };
75 |
76 | static const uint8_t u8x8_d_ld7032_60x32_powersave1_seq[] = {
77 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
78 | U8X8_CA(0x002, 0x000), /* Dot Matrix Display ON */
79 | U8X8_END_TRANSFER(), /* disable chip */
80 | U8X8_END() /* end of sequence */
81 | };
82 |
83 | static const uint8_t u8x8_d_ld7032_60x32_flip0_seq[] = {
84 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
85 | U8X8_CA(0x009, 0x000), /* Display Direction: reset default (x,y: min --> max) */
86 | U8X8_END_TRANSFER(), /* disable chip */
87 | U8X8_END() /* end of sequence */
88 | };
89 |
90 | static const uint8_t u8x8_d_ld7032_60x32_flip1_seq[] = {
91 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
92 | //U8X8_CA(0x009, 0x002), /* Display Direction: reset default (x,y: min --> max) */
93 | U8X8_END_TRANSFER(), /* disable chip */
94 | U8X8_END() /* end of sequence */
95 | };
96 |
97 |
98 | static uint8_t u8x8_d_ld7032_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
99 | {
100 | uint8_t x, c;
101 | uint8_t *ptr;
102 | switch(msg)
103 | {
104 | /* handled by the calling function
105 | case U8X8_MSG_DISPLAY_SETUP_MEMORY:
106 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ld7032_60x32_display_info);
107 | break;
108 | */
109 | case U8X8_MSG_DISPLAY_INIT:
110 | u8x8_d_helper_display_init(u8x8);
111 | u8x8_cad_SendSequence(u8x8, u8x8_d_ld7032_60x32_init_seq);
112 | break;
113 | case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
114 | if ( arg_int == 0 )
115 | u8x8_cad_SendSequence(u8x8, u8x8_d_ld7032_60x32_powersave0_seq);
116 | else
117 | u8x8_cad_SendSequence(u8x8, u8x8_d_ld7032_60x32_powersave1_seq);
118 | break;
119 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
120 | if ( arg_int == 0 )
121 | {
122 | u8x8_cad_SendSequence(u8x8, u8x8_d_ld7032_60x32_flip0_seq);
123 | u8x8->x_offset = u8x8->display_info->default_x_offset;
124 | }
125 | else
126 | {
127 | u8x8_cad_SendSequence(u8x8, u8x8_d_ld7032_60x32_flip1_seq);
128 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
129 | }
130 | break;
131 | #ifdef U8X8_WITH_SET_CONTRAST
132 | case U8X8_MSG_DISPLAY_SET_CONTRAST:
133 | u8x8_cad_StartTransfer(u8x8);
134 | u8x8_cad_SendCmd(u8x8, 0x012 );
135 | if ( arg_int > 0x07f ) /* default is 0x040, limit to 0x07f to be on the safe side (hopefully) */
136 | arg_int= 0x07f;
137 | u8x8_cad_SendArg(u8x8, arg_int ); /* values from 0x00 to 0x0ff are allowed, bit will all values be safe??? */
138 | u8x8_cad_EndTransfer(u8x8);
139 | break;
140 | #endif
141 | case U8X8_MSG_DISPLAY_DRAW_TILE:
142 | u8x8_cad_StartTransfer(u8x8);
143 | x = ((u8x8_tile_t *)arg_ptr)->x_pos;
144 | x += u8x8->x_offset/8;
145 | u8x8_cad_SendCmd(u8x8, 0x034 );
146 | u8x8_cad_SendArg(u8x8, x );
147 | u8x8_cad_SendCmd(u8x8, 0x035 );
148 | u8x8_cad_SendArg(u8x8, 0x007 );
149 | u8x8_cad_SendCmd(u8x8, 0x036 );
150 | u8x8_cad_SendArg(u8x8, (((u8x8_tile_t *)arg_ptr)->y_pos)*8 );
151 | u8x8_cad_SendCmd(u8x8, 0x037 );
152 | u8x8_cad_SendArg(u8x8, 0x01f );
153 | u8x8_cad_SendCmd(u8x8, 0x008 );
154 |
155 |
156 | do
157 | {
158 | c = ((u8x8_tile_t *)arg_ptr)->cnt;
159 | ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
160 | u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
161 | arg_int--;
162 | } while( arg_int > 0 );
163 |
164 | u8x8_cad_EndTransfer(u8x8);
165 | break;
166 | default:
167 | return 0;
168 | }
169 | return 1;
170 | }
171 |
172 |
173 | static const u8x8_display_info_t u8x8_ld7032_60x32_display_info =
174 | {
175 | /* chip_enable_level = */ 0,
176 | /* chip_disable_level = */ 1,
177 |
178 | /* post_chip_enable_wait_ns = */ 15,
179 | /* pre_chip_disable_wait_ns = */ 20,
180 | /* reset_pulse_width_ms = */ 100,
181 | /* post_reset_wait_ms = */ 100,
182 | /* sda_setup_time_ns = */ 30, /* 20ns, but cycle time is 60ns, so use 60/2 */
183 | /* sck_pulse_width_ns = */ 30, /* 20ns, but cycle time is 60ns, so use 60/2 */
184 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
185 | /* spi_mode = */ 0, /* active high, rising edge */
186 | /* i2c_bus_clock_100kHz = */ 4,
187 | /* data_setup_time_ns = */ 20,
188 | /* write_pulse_width_ns = */ 40,
189 | /* tile_width = */ 8,
190 | /* tile_hight = */ 4,
191 | /* default_x_offset = */ 0,
192 | /* flipmode_x_offset = */ 0,
193 | /* pixel_width = */ 60,
194 | /* pixel_height = */ 32
195 | };
196 |
197 | uint8_t u8x8_d_ld7032_60x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
198 | {
199 | if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
200 | {
201 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ld7032_60x32_display_info);
202 | return 1;
203 | }
204 | return u8x8_d_ld7032_generic(u8x8, msg, arg_int, arg_ptr);
205 | }
206 |
207 |
208 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8x8_d_ls013b7dh03.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8x8_d_ls013b7dh03.c
4 |
5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6 |
7 | Copyright (c) 2016, 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 | The LS013B7DH02 is a simple display and controller
36 | --> no support for contrast adjustment, flip and power down.
37 | */
38 |
39 | #include "u8x8.h"
40 |
41 | #define SWAP8(a) ((((a) & 0x80) >> 7) | (((a) & 0x40) >> 5) | (((a) & 0x20) >> 3) | (((a) & 0x10) >> 1) | (((a) & 0x08) << 1) | (((a) & 0x04) << 3) | (((a) & 0x02) << 5) | (((a) & 0x01) << 7))
42 |
43 | #define LS013B7DH03_CMD_UPDATE (0x01)
44 | #define LS013B7DH03_CMD_ALL_CLEAR (0x04)
45 | #define LS013B7DH03_VAL_TRAILER (0x00)
46 |
47 | static const u8x8_display_info_t u8x8_ls013b7dh03_128x128_display_info =
48 | {
49 | /* chip_enable_level = */ 1,
50 | /* chip_disable_level = */ 0,
51 | /* post_chip_enable_wait_ns = */ 50,
52 | /* pre_chip_disable_wait_ns = */ 50,
53 | /* reset_pulse_width_ms = */ 1,
54 | /* post_reset_wait_ms = */ 6,
55 | /* sda_setup_time_ns = */ 227, /* 227 nsec according to the datasheet */
56 | /* sck_pulse_width_ns = */ 255, /* 450 nsec according to the datasheet */
57 | /* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
58 | /* spi_mode = */ 2, /* active low, rising edge */
59 | /* i2c_bus_clock_100kHz = */ 4,
60 | /* data_setup_time_ns = */ 100,
61 | /* write_pulse_width_ns = */ 100,
62 | /* tile_width = */ 16,
63 | /* tile_hight = */ 16,
64 | /* default_x_offset = */ 0,
65 | /* flipmode_x_offset = */ 0,
66 | /* pixel_width = */ 128,
67 | /* pixel_height = */ 128
68 | };
69 |
70 | uint8_t u8x8_d_ls013b7dh03_128x128(u8x8_t *u8x8, uint8_t msg, U8X8_UNUSED uint8_t arg_int, void *arg_ptr)
71 | {
72 | uint8_t y, c, i;
73 | uint8_t *ptr;
74 | switch(msg)
75 | {
76 | case U8X8_MSG_DISPLAY_SETUP_MEMORY:
77 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_ls013b7dh03_128x128_display_info);
78 | break;
79 | case U8X8_MSG_DISPLAY_INIT:
80 | u8x8_d_helper_display_init(u8x8);
81 |
82 | /* clear screen */
83 | u8x8_cad_StartTransfer(u8x8);
84 | u8x8_cad_SendCmd(u8x8, SWAP8(LS013B7DH03_CMD_ALL_CLEAR) );
85 | u8x8_cad_SendCmd(u8x8, LS013B7DH03_VAL_TRAILER);
86 | u8x8_cad_EndTransfer(u8x8);
87 |
88 | break;
89 | case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
90 | /* not available for the ls013b7dh03 */
91 | break;
92 | case U8X8_MSG_DISPLAY_DRAW_TILE:
93 | /* each tile is 8 lines, with the data starting at the left edge */
94 | y = ((((u8x8_tile_t *)arg_ptr)->y_pos) * 8) + 1;
95 |
96 | c = ((u8x8_tile_t *)arg_ptr)->cnt;
97 | ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
98 |
99 | /* send data mode byte */
100 | u8x8_cad_StartTransfer(u8x8);
101 | u8x8_cad_SendCmd(u8x8, SWAP8(LS013B7DH03_CMD_UPDATE) );
102 |
103 | /* send 8 lines of 16 bytes (=128 pixels) */
104 | for( i = 0; i < 8; i++ )
105 | {
106 | u8x8_cad_SendCmd(u8x8, SWAP8(y + i) );
107 | u8x8_cad_SendData(u8x8, c, ptr);
108 | u8x8_cad_SendCmd(u8x8, LS013B7DH03_VAL_TRAILER);
109 |
110 | ptr += c;
111 | }
112 |
113 | /* finish with a trailing byte */
114 | u8x8_cad_SendCmd(u8x8, LS013B7DH03_VAL_TRAILER);
115 | u8x8_cad_EndTransfer(u8x8);
116 |
117 | break;
118 | default:
119 | return 0;
120 | }
121 | return 1;
122 | }
123 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8x8_d_max7219.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8x8_d_max7219.c
4 |
5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6 |
7 | Copyright (c) 2017, 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 "u8x8.h"
38 |
39 |
40 |
41 | static const uint8_t u8x8_d_max7219_init_seq[] = {
42 |
43 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
44 | U8X8_CA(15, 0), /* test mode off */
45 | U8X8_CA(15, 0), /* test mode off */
46 | U8X8_CA(15, 0), /* test mode off */
47 | U8X8_CA(15, 0), /* test mode off */
48 | U8X8_END_TRANSFER(), /* disable chip */
49 |
50 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
51 | U8X8_CA(12, 0), /* */
52 | U8X8_CA(12, 0), /* */
53 | U8X8_CA(12, 0), /* */
54 | U8X8_CA(12, 0), /* */
55 | U8X8_END_TRANSFER(), /* disable chip */
56 |
57 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
58 | U8X8_CA(9, 0), /* decode mode: graphics */
59 | U8X8_CA(9, 0), /* decode mode: graphics */
60 | U8X8_CA(9, 0), /* decode mode: graphics */
61 | U8X8_CA(9, 0), /* decode mode: graphics */
62 | U8X8_END_TRANSFER(), /* disable chip */
63 |
64 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
65 | U8X8_CA(10, 10), /* medium high intensity */
66 | U8X8_CA(10, 10), /* medium high intensity */
67 | U8X8_CA(10, 10), /* medium high intensity */
68 | U8X8_CA(10, 10), /* medium high intensity */
69 | U8X8_END_TRANSFER(), /* disable chip */
70 |
71 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
72 | U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
73 | U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
74 | U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
75 | U8X8_CA(11, 7), /* scan limit: display all digits (assuming a 8x8 matrix) */
76 | U8X8_END_TRANSFER(), /* disable chip */
77 |
78 |
79 | //U8X8_CA(12, 0), /* shutdown */
80 |
81 | //U8X8_END_TRANSFER(), /* disable chip */
82 | U8X8_END() /* end of sequence */
83 | };
84 |
85 | static const uint8_t u8x8_d_max7219_powersave0_seq[] = {
86 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
87 | U8X8_CA(12, 1), /* display on */
88 | U8X8_CA(12, 1), /* display on */
89 | U8X8_CA(12, 1), /* display on */
90 | U8X8_CA(12, 1), /* display on */
91 | U8X8_END_TRANSFER(), /* disable chip */
92 | U8X8_END() /* end of sequence */
93 | };
94 |
95 | static const uint8_t u8x8_d_max7219_powersave1_seq[] = {
96 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
97 | U8X8_CA(12, 0), /* shutdown */
98 | U8X8_CA(12, 0), /* shutdown */
99 | U8X8_CA(12, 0), /* shutdown */
100 | U8X8_CA(12, 0), /* shutdown */
101 | U8X8_END_TRANSFER(), /* disable chip */
102 | U8X8_END() /* end of sequence */
103 | };
104 |
105 |
106 | static uint8_t u8x8_d_max7219_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
107 | {
108 | uint8_t c, j, i;
109 | uint8_t *ptr;
110 | switch(msg)
111 | {
112 | /* handled by the calling function
113 | case U8X8_MSG_DISPLAY_SETUP_MEMORY:
114 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_pcf8812_96x65_display_info);
115 | break;
116 | */
117 | case U8X8_MSG_DISPLAY_INIT:
118 | u8x8_d_helper_display_init(u8x8);
119 | u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_init_seq);
120 | break;
121 | case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
122 | if ( arg_int == 0 )
123 | u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_powersave0_seq);
124 | else
125 | u8x8_cad_SendSequence(u8x8, u8x8_d_max7219_powersave1_seq);
126 | break;
127 | /* not supported by MAX7219
128 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
129 | break;
130 | */
131 | #ifdef U8X8_WITH_SET_CONTRAST
132 | case U8X8_MSG_DISPLAY_SET_CONTRAST:
133 | u8x8_cad_StartTransfer(u8x8);
134 | u8x8_cad_SendCmd(u8x8, 10 ); /* brightness */
135 | u8x8_cad_SendArg(u8x8, (arg_int>>4) ); /* 0..15 for contrast */
136 | u8x8_cad_SendCmd(u8x8, 10 ); /* brightness */
137 | u8x8_cad_SendArg(u8x8, (arg_int>>4) ); /* 0..15 for contrast */
138 | u8x8_cad_SendCmd(u8x8, 10 ); /* brightness */
139 | u8x8_cad_SendArg(u8x8, (arg_int>>4) ); /* 0..15 for contrast */
140 | u8x8_cad_SendCmd(u8x8, 10 ); /* brightness */
141 | u8x8_cad_SendArg(u8x8, (arg_int>>4) ); /* 0..15 for contrast */
142 | u8x8_cad_EndTransfer(u8x8);
143 | break;
144 | #endif
145 | case U8X8_MSG_DISPLAY_DRAW_TILE:
146 | /* transfer always has to start at x pos 0 (u8x8 is not supported) */
147 | /* also y pos has to be 0 */
148 | /* arg_int is ignored */
149 | //x = ((u8x8_tile_t *)arg_ptr)->x_pos;
150 |
151 | c = ((u8x8_tile_t *)arg_ptr)->cnt; /* number of tiles */
152 | ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr; /* data ptr to the tiles */
153 | for( i = 0; i < 8; i++ )
154 | {
155 | u8x8_cad_StartTransfer(u8x8);
156 | for( j = 0; j < c; j++ )
157 | {
158 | u8x8_cad_SendCmd(u8x8, i+1);
159 | u8x8_cad_SendArg(u8x8, *ptr );
160 | ptr++;
161 | }
162 | u8x8_cad_EndTransfer(u8x8);
163 | }
164 |
165 | break;
166 | default:
167 | return 0;
168 | }
169 | return 1;
170 | }
171 |
172 |
173 | static const u8x8_display_info_t u8x8_max7219_32x8_display_info =
174 | {
175 | /* chip_enable_level = */ 0,
176 | /* chip_disable_level = */ 1,
177 |
178 | /* post_chip_enable_wait_ns = */ 100,
179 | /* pre_chip_disable_wait_ns = */ 100,
180 | /* reset_pulse_width_ms = */ 100,
181 | /* post_reset_wait_ms = */ 100,
182 | /* sda_setup_time_ns = */ 100,
183 | /* sck_pulse_width_ns = */ 100,
184 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
185 | /* spi_mode = */ 0, /* active high, rising edge */
186 | /* i2c_bus_clock_100kHz = */ 4,
187 | /* data_setup_time_ns = */ 40,
188 | /* write_pulse_width_ns = */ 150,
189 | /* tile_width = */ 4,
190 | /* tile_hight = */ 1,
191 | /* default_x_offset = */ 0,
192 | /* flipmode_x_offset = */ 0,
193 | /* pixel_width = */ 32,
194 | /* pixel_height = */ 16
195 | };
196 |
197 | uint8_t u8x8_d_max7219_32x8(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
198 | {
199 | if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
200 | {
201 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_max7219_32x8_display_info);
202 | return 1;
203 | }
204 | return u8x8_d_max7219_generic(u8x8, msg, arg_int, arg_ptr);
205 | }
206 |
207 |
208 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8x8_d_pcd8544_84x48.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8x8_d_pcd8544_84x48.c (so called "Nokia 5110" displays)
4 |
5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6 |
7 | Copyright (c) 2016, olikraus@gmail.com
8 | All rights reserved.
9 |
10 | Redistribution and use in source and binary forms, with or without modification,
11 | are permitted provided that the following conditions are met:
12 |
13 | * Redistributions of source code must retain the above copyright notice, this list
14 | of conditions and the following disclaimer.
15 |
16 | * Redistributions in binary form must reproduce the above copyright notice, this
17 | list of conditions and the following disclaimer in the documentation and/or other
18 | materials provided with the distribution.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
21 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 |
34 |
35 | */
36 | #include "u8x8.h"
37 |
38 |
39 |
40 |
41 | static const uint8_t u8x8_d_pcd8544_84x48_init_seq[] = {
42 |
43 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
44 |
45 | U8X8_C(0x021), /* activate chip (PD=0), horizontal increment (V=0), enter extended command set (H=1) */
46 | U8X8_C(0x006), /* temp. control: b10 = 2 */
47 | U8X8_C(0x013), /* bias system 1:48 */
48 | U8X8_C(0x0c0), /* medium Vop */
49 |
50 | U8X8_C(0x020), /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
51 | U8X8_C(0x008), /* blank */
52 | U8X8_C(0x024), /* power down (PD=1), horizontal increment (V=0), enter normal command set (H=0) */
53 |
54 | U8X8_END_TRANSFER(), /* disable chip */
55 | U8X8_END() /* end of sequence */
56 | };
57 |
58 | static const uint8_t u8x8_d_pcd8544_84x48_powersave0_seq[] = {
59 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
60 | U8X8_C(0x020), /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
61 | U8X8_C(0x00c), /* display on */
62 | U8X8_END_TRANSFER(), /* disable chip */
63 | U8X8_END() /* end of sequence */
64 | };
65 |
66 | static const uint8_t u8x8_d_pcd8544_84x48_powersave1_seq[] = {
67 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
68 | U8X8_C(0x020), /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
69 | U8X8_C(0x008), /* blank */
70 | U8X8_C(0x024), /* power down (PD=1), horizontal increment (V=0), enter normal command set (H=0) */
71 | U8X8_END_TRANSFER(), /* disable chip */
72 | U8X8_END() /* end of sequence */
73 | };
74 |
75 |
76 |
77 | static const u8x8_display_info_t u8x8_pcd8544_84x48_display_info =
78 | {
79 | /* chip_enable_level = */ 0,
80 | /* chip_disable_level = */ 1,
81 |
82 | /* post_chip_enable_wait_ns = */ 5,
83 | /* pre_chip_disable_wait_ns = */ 5,
84 | /* reset_pulse_width_ms = */ 2,
85 | /* post_reset_wait_ms = */ 2,
86 | /* sda_setup_time_ns = */ 12,
87 | /* sck_pulse_width_ns = */ 75, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
88 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
89 | /* spi_mode = */ 0, /* active high, rising edge */
90 | /* i2c_bus_clock_100kHz = */ 4,
91 | /* data_setup_time_ns = */ 30,
92 | /* write_pulse_width_ns = */ 40,
93 | /* tile_width = */ 11, /* width of 11*8=88 pixel */
94 | /* tile_hight = */ 6,
95 | /* default_x_offset = */ 0,
96 | /* flipmode_x_offset = */ 0,
97 | /* pixel_width = */ 84,
98 | /* pixel_height = */ 48
99 | };
100 |
101 | uint8_t u8x8_d_pcd8544_84x48(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
102 | {
103 | uint8_t x, c;
104 | uint8_t *ptr;
105 | switch(msg)
106 | {
107 | case U8X8_MSG_DISPLAY_SETUP_MEMORY:
108 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_pcd8544_84x48_display_info);
109 | break;
110 | case U8X8_MSG_DISPLAY_INIT:
111 | u8x8_d_helper_display_init(u8x8);
112 | u8x8_cad_SendSequence(u8x8, u8x8_d_pcd8544_84x48_init_seq);
113 | break;
114 | case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
115 | if ( arg_int == 0 )
116 | u8x8_cad_SendSequence(u8x8, u8x8_d_pcd8544_84x48_powersave0_seq);
117 | else
118 | u8x8_cad_SendSequence(u8x8, u8x8_d_pcd8544_84x48_powersave1_seq);
119 | break;
120 | // case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
121 | // break; NOT SUPPORTED
122 |
123 | #ifdef U8X8_WITH_SET_CONTRAST
124 | case U8X8_MSG_DISPLAY_SET_CONTRAST:
125 | u8x8_cad_StartTransfer(u8x8);
126 | u8x8_cad_SendCmd(u8x8, 0x021 ); /* command mode, extended function set */
127 | u8x8_cad_SendCmd(u8x8, 0x080 | (arg_int >> 1) );
128 | u8x8_cad_EndTransfer(u8x8);
129 | break;
130 | #endif
131 | case U8X8_MSG_DISPLAY_DRAW_TILE:
132 | u8x8_cad_StartTransfer(u8x8);
133 |
134 | x = ((u8x8_tile_t *)arg_ptr)->x_pos;
135 | x *= 8;
136 | x += u8x8->x_offset;
137 | u8x8_cad_SendCmd(u8x8, 0x020 ); /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
138 | u8x8_cad_SendCmd(u8x8, 0x080 | (x) ); /* set X address */
139 | u8x8_cad_SendCmd(u8x8, 0x040 | (((u8x8_tile_t *)arg_ptr)->y_pos) ); /* set Y address */
140 |
141 | ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
142 | c = ((u8x8_tile_t *)arg_ptr)->cnt;
143 | c *= 8;
144 | do
145 | {
146 | if ( c + x > 84u )
147 | {
148 | if ( x >= 84u )
149 | break;
150 | c = 84u;
151 | c -= x;
152 | }
153 | u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
154 | x += c;
155 | arg_int--;
156 | } while( arg_int > 0 );
157 |
158 | u8x8_cad_EndTransfer(u8x8);
159 | break;
160 | default:
161 | return 0;
162 | }
163 | return 1;
164 | }
165 |
166 |
167 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8x8_d_pcf8812.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8x8_d_pcf8812.c
4 |
5 | pcf8812: 65x102
6 | pcf8814: 65x96
7 |
8 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
9 |
10 | Copyright (c) 2017, 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 "u8x8.h"
41 |
42 |
43 |
44 | static const uint8_t u8x8_d_pcf8812_96x65_init_seq[] = {
45 |
46 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
47 |
48 | U8X8_C(0x020), /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
49 | U8X8_C(0x008), /* blank display */
50 |
51 | U8X8_C(0x021), /* activate chip (PD=0), horizontal increment (V=0), enter extended command set (H=1) */
52 | U8X8_C(0x006), /* temp. control: b10 = 2 */
53 | U8X8_C(0x013), /* bias system, 0x010..0x07 1:48 */
54 | U8X8_C(0x09f), /* contrast setting, 0..127 */
55 | //U8X8_CA(0x020 | 2, 0x080 | 0), /* contrast setting, pcf8814 */
56 |
57 | U8X8_C(0x024), /* deactivate chip (PD=1), horizontal increment (V=0), enter normal command set (H=0) */
58 |
59 | U8X8_END_TRANSFER(), /* disable chip */
60 | U8X8_END() /* end of sequence */
61 | };
62 |
63 | static const uint8_t u8x8_d_pcf8812_96x65_powersave0_seq[] = {
64 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
65 | U8X8_C(0x020), /* power on */
66 | U8X8_C(0x00c), /* display on */
67 | U8X8_END_TRANSFER(), /* disable chip */
68 | U8X8_END() /* end of sequence */
69 | };
70 |
71 | static const uint8_t u8x8_d_pcf8812_96x65_powersave1_seq[] = {
72 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
73 | U8X8_C(0x020), /* power on */
74 | U8X8_C(0x008), /* blank display */
75 | U8X8_C(0x024), /* power down */
76 | U8X8_END_TRANSFER(), /* disable chip */
77 | U8X8_END() /* end of sequence */
78 | };
79 |
80 |
81 | static uint8_t u8x8_d_pcf8812_96x65_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
82 | {
83 | uint8_t x, c;
84 | uint8_t *ptr;
85 | switch(msg)
86 | {
87 | /* handled by the calling function
88 | case U8X8_MSG_DISPLAY_SETUP_MEMORY:
89 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_pcf8812_96x65_display_info);
90 | break;
91 | */
92 | case U8X8_MSG_DISPLAY_INIT:
93 | u8x8_d_helper_display_init(u8x8);
94 | u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_96x65_init_seq);
95 | break;
96 | case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
97 | if ( arg_int == 0 )
98 | u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_96x65_powersave0_seq);
99 | else
100 | u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_96x65_powersave1_seq);
101 | break;
102 | /*
103 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
104 | if ( arg_int == 0 )
105 | {
106 | u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_96x65_flip0_seq);
107 | u8x8->x_offset = u8x8->display_info->default_x_offset;
108 | }
109 | else
110 | {
111 | u8x8_cad_SendSequence(u8x8, u8x8_d_pcf8812_96x65_flip1_seq);
112 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
113 | }
114 | break;
115 | */
116 | #ifdef U8X8_WITH_SET_CONTRAST
117 | case U8X8_MSG_DISPLAY_SET_CONTRAST:
118 | u8x8_cad_StartTransfer(u8x8);
119 | u8x8_cad_SendCmd(u8x8, 0x021 ); /* command mode, extended function set */
120 | u8x8_cad_SendArg(u8x8, (arg_int>>1)|0x80 ); /* 0..127 for contrast */
121 | u8x8_cad_EndTransfer(u8x8);
122 | break;
123 | #endif
124 | case U8X8_MSG_DISPLAY_DRAW_TILE:
125 | u8x8_cad_StartTransfer(u8x8);
126 | x = ((u8x8_tile_t *)arg_ptr)->x_pos;
127 | x *= 8;
128 | x += u8x8->x_offset;
129 |
130 | u8x8_cad_SendCmd(u8x8, 0x020 ); /* activate chip (PD=0), horizontal increment (V=0), enter normal command set (H=0) */
131 | u8x8_cad_SendCmd(u8x8, 0x080 | x);
132 | u8x8_cad_SendCmd(u8x8, 0x040 | ((u8x8_tile_t *)arg_ptr)->y_pos);
133 |
134 | do
135 | {
136 | c = ((u8x8_tile_t *)arg_ptr)->cnt;
137 | ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
138 | u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
139 | /*
140 | do
141 | {
142 | u8x8_cad_SendData(u8x8, 8, ptr);
143 | ptr += 8;
144 | c--;
145 | } while( c > 0 );
146 | */
147 | arg_int--;
148 | } while( arg_int > 0 );
149 |
150 | u8x8_cad_EndTransfer(u8x8);
151 | break;
152 | default:
153 | return 0;
154 | }
155 | return 1;
156 | }
157 |
158 |
159 | static const u8x8_display_info_t u8x8_pcf8812_96x65_display_info =
160 | {
161 | /* chip_enable_level = */ 0,
162 | /* chip_disable_level = */ 1,
163 |
164 | /* post_chip_enable_wait_ns = */ 100,
165 | /* pre_chip_disable_wait_ns = */ 100,
166 | /* reset_pulse_width_ms = */ 100,
167 | /* post_reset_wait_ms = */ 100,
168 | /* sda_setup_time_ns = */ 100,
169 | /* sck_pulse_width_ns = */ 100,
170 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
171 | /* spi_mode = */ 0, /* active high, rising edge */
172 | /* i2c_bus_clock_100kHz = */ 4,
173 | /* data_setup_time_ns = */ 40,
174 | /* write_pulse_width_ns = */ 150,
175 | /* tile_width = */ 12,
176 | /* tile_hight = */ 9,
177 | /* default_x_offset = */ 0,
178 | /* flipmode_x_offset = */ 0,
179 | /* pixel_width = */ 96,
180 | /* pixel_height = */ 65
181 | };
182 |
183 | uint8_t u8x8_d_pcf8812_96x65(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
184 | {
185 | if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
186 | {
187 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_pcf8812_96x65_display_info);
188 | return 1;
189 | }
190 | return u8x8_d_pcf8812_96x65_generic(u8x8, msg, arg_int, arg_ptr);
191 | }
192 |
193 |
194 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8x8_d_pcf8814_hx1230.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8x8_d_pcf8814_hc1230.c
4 |
5 | pcf8814: 65x96
6 | hx1230: 68x96
7 |
8 | pcf8814 and hc1230 are almost identical. Flip mode is not supported.
9 |
10 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
11 |
12 | Copyright (c) 2017, 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 "u8x8.h"
43 |
44 |
45 |
46 | static const uint8_t u8x8_d_hx1230_96x68_init_seq[] = {
47 |
48 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
49 |
50 | U8X8_C(0x0ae), /* display off */
51 | U8X8_C(0x020), /* power off */
52 | U8X8_C(0x080), /* contrast setting, 0..31, set to 0 */
53 | U8X8_C(0x0a6), /* not inverted display */
54 | U8X8_C(0x0a4), /* normal display mode */
55 |
56 | U8X8_C(0x040), /* start at scanline 0 */
57 |
58 | U8X8_END_TRANSFER(), /* disable chip */
59 | U8X8_END() /* end of sequence */
60 | };
61 |
62 | static const uint8_t u8x8_d_hx1230_96x68_powersave0_seq[] = {
63 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
64 | U8X8_C(0x02f), /* power on */
65 | U8X8_C(0x0af), /* display on */
66 | U8X8_END_TRANSFER(), /* disable chip */
67 | U8X8_END() /* end of sequence */
68 | };
69 |
70 | static const uint8_t u8x8_d_hx1230_96x68_powersave1_seq[] = {
71 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
72 | U8X8_C(0x0a4), /* display off */
73 | U8X8_C(0x020), /* power off */
74 | U8X8_END_TRANSFER(), /* disable chip */
75 | U8X8_END() /* end of sequence */
76 | };
77 |
78 |
79 | static uint8_t u8x8_d_hx1230_96x68_generic(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
80 | {
81 | uint8_t x, c;
82 | uint8_t *ptr;
83 | switch(msg)
84 | {
85 | /* handled by the calling function
86 | case U8X8_MSG_DISPLAY_SETUP_MEMORY:
87 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_hx1230_96x68_display_info);
88 | break;
89 | */
90 | case U8X8_MSG_DISPLAY_INIT:
91 | u8x8_d_helper_display_init(u8x8);
92 | u8x8_cad_SendSequence(u8x8, u8x8_d_hx1230_96x68_init_seq);
93 | break;
94 | case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
95 | if ( arg_int == 0 )
96 | u8x8_cad_SendSequence(u8x8, u8x8_d_hx1230_96x68_powersave0_seq);
97 | else
98 | u8x8_cad_SendSequence(u8x8, u8x8_d_hx1230_96x68_powersave1_seq);
99 | break;
100 | /*
101 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
102 | if ( arg_int == 0 )
103 | {
104 | u8x8_cad_SendSequence(u8x8, u8x8_d_hx1230_96x68_flip0_seq);
105 | u8x8->x_offset = u8x8->display_info->default_x_offset;
106 | }
107 | else
108 | {
109 | u8x8_cad_SendSequence(u8x8, u8x8_d_hx1230_96x68_flip1_seq);
110 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
111 | }
112 | break;
113 | */
114 | #ifdef U8X8_WITH_SET_CONTRAST
115 | case U8X8_MSG_DISPLAY_SET_CONTRAST:
116 | u8x8_cad_StartTransfer(u8x8);
117 | u8x8_cad_SendCmd(u8x8, (arg_int>>3)|0x80 ); /* 0..31 for contrast */
118 | u8x8_cad_EndTransfer(u8x8);
119 | break;
120 | #endif
121 | case U8X8_MSG_DISPLAY_DRAW_TILE:
122 | u8x8_cad_StartTransfer(u8x8);
123 | x = ((u8x8_tile_t *)arg_ptr)->x_pos;
124 | x *= 8;
125 | x += u8x8->x_offset;
126 |
127 | u8x8_cad_SendCmd(u8x8, x&15);
128 | u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4));
129 | u8x8_cad_SendCmd(u8x8, 0x0b0 | ((u8x8_tile_t *)arg_ptr)->y_pos);
130 |
131 | do
132 | {
133 | c = ((u8x8_tile_t *)arg_ptr)->cnt;
134 | ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
135 | u8x8_cad_SendData(u8x8, c*8, ptr); /* note: SendData can not handle more than 255 bytes */
136 | arg_int--;
137 | } while( arg_int > 0 );
138 |
139 | u8x8_cad_EndTransfer(u8x8);
140 | break;
141 | default:
142 | return 0;
143 | }
144 | return 1;
145 | }
146 |
147 | static const u8x8_display_info_t u8x8_hx1230_96x68_display_info =
148 | {
149 | /* chip_enable_level = */ 0,
150 | /* chip_disable_level = */ 1,
151 |
152 | /* post_chip_enable_wait_ns = */ 100,
153 | /* pre_chip_disable_wait_ns = */ 100,
154 | /* reset_pulse_width_ms = */ 100,
155 | /* post_reset_wait_ms = */ 100,
156 | /* sda_setup_time_ns = */ 100,
157 | /* sck_pulse_width_ns = */ 100,
158 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
159 | /* spi_mode = */ 0, /* active high, rising edge */
160 | /* i2c_bus_clock_100kHz = */ 4,
161 | /* data_setup_time_ns = */ 40,
162 | /* write_pulse_width_ns = */ 150,
163 | /* tile_width = */ 12,
164 | /* tile_hight = */ 9,
165 | /* default_x_offset = */ 0,
166 | /* flipmode_x_offset = */ 0,
167 | /* pixel_width = */ 96,
168 | /* pixel_height = */ 68
169 | };
170 |
171 | uint8_t u8x8_d_hx1230_96x68(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
172 | {
173 | if ( msg == U8X8_MSG_DISPLAY_SETUP_MEMORY )
174 | {
175 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_hx1230_96x68_display_info);
176 | return 1;
177 | }
178 | return u8x8_d_hx1230_96x68_generic(u8x8, msg, arg_int, arg_ptr);
179 | }
180 |
181 |
182 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8x8_d_sbn1661.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8x8_d_sbn1661.c
4 |
5 | SED1520 / SBN1661 122x32 5V LCD
6 |
7 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
8 |
9 | Copyright (c) 2016, 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 "u8x8.h"
39 |
40 |
41 |
42 |
43 | static const uint8_t u8x8_d_sbn1661_init_seq[] = {
44 | U8X8_C(0x0c0), /* display start at line 0 */
45 | U8X8_C(0x0a0), /* a0: ADC forward, a1: ADC reverse */
46 | U8X8_C(0x0a4), /* a4: normal driving, a5: power save */
47 | U8X8_C(0x0a9), /* a8: 1/16, a9: 1/32 duty */
48 |
49 | //U8X8_C(0x0af), /* display on */
50 |
51 | U8X8_END() /* end of sequence */
52 | };
53 |
54 | static const uint8_t u8x8_d_sbn1661_powersave0_seq[] = {
55 | U8X8_C(0x0af), /* display on */
56 | U8X8_END() /* end of sequence */
57 | };
58 |
59 | static const uint8_t u8x8_d_sbn1661_powersave1_seq[] = {
60 | U8X8_C(0x0ae), /* display off */
61 | U8X8_END() /* end of sequence */
62 | };
63 |
64 |
65 | struct u8x8_sbn1661_vars
66 | {
67 | uint8_t *ptr;
68 | uint8_t x;
69 | uint8_t c;
70 | uint8_t arg_int;
71 | };
72 |
73 | #ifdef NOT_USED
74 | static void u8x8_sbn1661_out(u8x8_t *u8x8, struct u8x8_sbn1661_vars *v, void *arg_ptr)
75 | {
76 | uint8_t cnt;
77 | u8x8_cad_SendCmd(u8x8, 0x000 | ((v->x << 3) & 63) );
78 | u8x8_cad_SendCmd(u8x8, 0x0b8 | (((u8x8_tile_t *)arg_ptr)->y_pos));
79 |
80 | while( v->arg_int > 0 )
81 | {
82 | /* calculate tiles to next boundary (end or chip limit) */
83 | cnt = v->x;
84 | cnt += 8;
85 | cnt &= 0x0f8;
86 | cnt -= v->x;
87 |
88 | if ( cnt > v->c )
89 | cnt = v->c;
90 |
91 | /* of course we still could use cnt=1 here... */
92 | /* but setting cnt to 1 is not very efficient */
93 | //cnt = 1;
94 |
95 | v->x +=cnt;
96 | v->c-=cnt;
97 | cnt<<=3;
98 | u8x8_cad_SendData(u8x8, cnt, v->ptr); /* note: SendData can not handle more than 255 bytes */
99 | v->ptr += cnt;
100 |
101 | if ( v->c == 0 )
102 | {
103 | v->ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
104 | v->c = ((u8x8_tile_t *)arg_ptr)->cnt;
105 | v->arg_int--;
106 | }
107 | if ( ((v->x) & 7) == 0 )
108 | break;
109 | }
110 | }
111 | #endif /* NOT_USED */
112 |
113 |
114 | static const u8x8_display_info_t u8x8_sbn1661_122x32_display_info =
115 | {
116 | /* chip_enable_level = */ 0, /* sbn1661: Not used */
117 | /* chip_disable_level = */ 1, /* sbn1661: Not used */
118 |
119 | /* post_chip_enable_wait_ns = */ 100,
120 | /* pre_chip_disable_wait_ns = */ 20,
121 | /* reset_pulse_width_ms = */ 1,
122 | /* post_reset_wait_ms = */ 6, /* */
123 | /* sda_setup_time_ns = */ 12,
124 | /* sck_pulse_width_ns = */ 75, /* sbn1661: Not used */
125 | /* sck_clock_hz = */ 4000000UL, /* sbn1661: Not used */
126 | /* spi_mode = */ 0, /* active high, rising edge */
127 | /* i2c_bus_clock_100kHz = */ 4, /* sbn1661: Not used */
128 | /* data_setup_time_ns = */ 200,
129 | /* write_pulse_width_ns = */ 200, /* */
130 | /* tile_width = */ 16, /* width of 16*8=128 pixel */
131 | /* tile_hight = */ 4,
132 | /* default_x_offset = */ 0,
133 | /* flipmode_x_offset = */ 0,
134 | /* pixel_width = */ 122,
135 | /* pixel_height = */ 32
136 | };
137 |
138 | uint8_t u8x8_d_sbn1661_122x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
139 | {
140 | uint8_t *ptr;
141 | //uint8_t x;
142 | //uint8_t c;
143 |
144 | switch(msg)
145 | {
146 | case U8X8_MSG_DISPLAY_SETUP_MEMORY:
147 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_sbn1661_122x32_display_info);
148 | break;
149 | case U8X8_MSG_DISPLAY_INIT:
150 | u8x8_d_helper_display_init(u8x8);
151 |
152 | u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 0, NULL);
153 | u8x8_cad_SendSequence(u8x8, u8x8_d_sbn1661_init_seq);
154 | u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
155 |
156 | u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
157 | u8x8_cad_SendSequence(u8x8, u8x8_d_sbn1661_init_seq);
158 | u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 1, NULL);
159 | break;
160 | case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
161 |
162 | if ( arg_int == 0 )
163 | {
164 | u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 0, NULL);
165 | u8x8_cad_SendSequence(u8x8, u8x8_d_sbn1661_powersave0_seq);
166 | u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
167 |
168 | u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
169 | u8x8_cad_SendSequence(u8x8, u8x8_d_sbn1661_powersave0_seq);
170 | u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 1, NULL);
171 | }
172 | else
173 | {
174 | u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 0, NULL);
175 | u8x8_cad_SendSequence(u8x8, u8x8_d_sbn1661_powersave1_seq);
176 | u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
177 |
178 | u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
179 | u8x8_cad_SendSequence(u8x8, u8x8_d_sbn1661_powersave1_seq);
180 | u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 1, NULL);
181 |
182 | }
183 | break;
184 | case U8X8_MSG_DISPLAY_DRAW_TILE:
185 |
186 | ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
187 | // x and c are ignored (u8g2 only)
188 | //x = ((u8x8_tile_t *)arg_ptr)->x_pos;
189 | //c = ((u8x8_tile_t *)arg_ptr)->cnt;
190 |
191 | u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 0, NULL);
192 | u8x8_cad_SendCmd(u8x8, 0x000 | 0); // column 0
193 | u8x8_cad_SendCmd(u8x8, 0x0b8 | (((u8x8_tile_t *)arg_ptr)->y_pos));
194 | u8x8_cad_SendData(u8x8, 61, ptr); /* note: SendData can not handle more than 255 bytes */
195 | u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 0, NULL);
196 |
197 | ptr += 61;
198 |
199 | u8x8->cad_cb(u8x8, U8X8_MSG_CAD_START_TRANSFER, 1, NULL);
200 | u8x8_cad_SendCmd(u8x8, 0x000 | 0); // column 0
201 | u8x8_cad_SendCmd(u8x8, 0x0b8 | (((u8x8_tile_t *)arg_ptr)->y_pos));
202 |
203 | u8x8_cad_SendData(u8x8, 61, ptr); /* note: SendData can not handle more than 255 bytes */
204 | u8x8->cad_cb(u8x8, U8X8_MSG_CAD_END_TRANSFER, 1, NULL);
205 |
206 | break;
207 | default:
208 | return 0;
209 | }
210 | return 1;
211 | }
212 |
213 | uint8_t u8x8_d_sed1520_122x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
214 | {
215 | return u8x8_d_sbn1661_122x32(u8x8, msg, arg_int, arg_ptr);
216 |
217 | }
218 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8x8_d_uc1601.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8x8_d_uc1601.c
4 |
5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6 |
7 | Copyright (c) 2017, 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 | This is for the uc1601s controller
35 |
36 |
37 | */
38 | #include "u8x8.h"
39 |
40 |
41 |
42 |
43 | static const uint8_t u8x8_d_uc1601_128x32_powersave0_seq[] = {
44 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
45 | U8X8_C(0x0af), /* display on */
46 | U8X8_END_TRANSFER(), /* disable chip */
47 | U8X8_END() /* end of sequence */
48 | };
49 |
50 | static const uint8_t u8x8_d_uc1601_128x32_powersave1_seq[] = {
51 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
52 | U8X8_C(0x0ae), /* display off */
53 | U8X8_END_TRANSFER(), /* disable chip */
54 | U8X8_END() /* end of sequence */
55 | };
56 |
57 | static const uint8_t u8x8_d_uc1601_128x32_flip0_seq[] = {
58 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
59 | U8X8_C(0x0c4), /* bit 1: MX, bit 2: MY */
60 | U8X8_C(0x060), /* set display start line to 32 */
61 | U8X8_END_TRANSFER(), /* disable chip */
62 | U8X8_END() /* end of sequence */
63 | };
64 |
65 | static const uint8_t u8x8_d_uc1601_128x32_flip1_seq[] = {
66 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
67 | U8X8_C(0x0c2), /* bit 1: MX, bit 2: MY */
68 | U8X8_C(0x040), /* set display start line to 0 */
69 | U8X8_END_TRANSFER(), /* disable chip */
70 | U8X8_END() /* end of sequence */
71 | };
72 |
73 |
74 | static const u8x8_display_info_t u8x8_uc1601_128x32_display_info =
75 | {
76 | /* chip_enable_level = */ 0,
77 | /* chip_disable_level = */ 1,
78 |
79 | /* post_chip_enable_wait_ns = */ 1, /* uc1601 datasheet, page 46 */
80 | /* pre_chip_disable_wait_ns = */ 5, /* uc1601 datasheet, page 46 */
81 | /* reset_pulse_width_ms = */ 1,
82 | /* post_reset_wait_ms = */ 6,
83 | /* sda_setup_time_ns = */ 12, /* uc1601 datasheet, page 44 */
84 | /* sck_pulse_width_ns = */ 15, /* uc1601 datasheet, page 44 */
85 | /* sck_clock_hz = */ 2000000UL, /* */
86 | /* spi_mode = */ 0, /* active high, rising edge */
87 | /* i2c_bus_clock_100kHz = */ 1,
88 | /* data_setup_time_ns = */ 60, /* uc1601 datasheet, page 43 */
89 | /* write_pulse_width_ns = */ 80, /* uc1601 datasheet, page 43 */
90 | /* tile_width = */ 16,
91 | /* tile_hight = */ 4,
92 | /* default_x_offset = */ 0,
93 | /* flipmode_x_offset = */ 4,
94 | /* pixel_width = */ 128,
95 | /* pixel_height = */ 32
96 | };
97 |
98 | static const uint8_t u8x8_d_uc1601_128x32_init_seq[] = {
99 |
100 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
101 |
102 | U8X8_C(0x0e2), /* soft reset */
103 | U8X8_C(0x0eb), /* LCD Bias: 0xe8: 6, 0xe9: 7, 0xea: 8, 0xeb: 9 */
104 | //U8X8_C(0x023), /* 0x020...0x023 only for UC1601, not for UC1601s */
105 |
106 |
107 | //U8X8_C(0x02e), /* LCD Load + Internal Charge Pump (default: 0x2e) */
108 | U8X8_C(0x024), /* Temperature Compenstation, default: 0x24 */
109 | U8X8_C(0x089), /* RAM address ctrl, default: 0x89 */
110 | U8X8_C(0x0c4), /* RAM mapping ctrl */
111 | U8X8_C(0x0a0), /* Frame Rate, 0x0a0 or 0x0a1 */
112 | U8X8_CA(0x081, 0x0df), /* set contrast */
113 | U8X8_C(0x02e), /* LCD Load + Internal Charge Pump (default: 0x2e) */
114 | U8X8_C(0x060), /* set display start line to 32 */
115 |
116 | U8X8_C(0x0a6), /* normal display */
117 |
118 | U8X8_END_TRANSFER(), /* disable chip */
119 | U8X8_END() /* end of sequence */
120 | };
121 |
122 | uint8_t u8x8_d_uc1601_128x32(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
123 | {
124 | uint8_t x, c;
125 | uint8_t *ptr;
126 | switch(msg)
127 | {
128 | case U8X8_MSG_DISPLAY_SETUP_MEMORY:
129 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1601_128x32_display_info);
130 | break;
131 | case U8X8_MSG_DISPLAY_INIT:
132 | u8x8_d_helper_display_init(u8x8);
133 | u8x8_cad_SendSequence(u8x8, u8x8_d_uc1601_128x32_init_seq);
134 | break;
135 | case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
136 | if ( arg_int == 0 )
137 | u8x8_cad_SendSequence(u8x8, u8x8_d_uc1601_128x32_powersave0_seq);
138 | else
139 | u8x8_cad_SendSequence(u8x8, u8x8_d_uc1601_128x32_powersave1_seq);
140 | break;
141 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
142 | if ( arg_int == 0 )
143 | {
144 | u8x8_cad_SendSequence(u8x8, u8x8_d_uc1601_128x32_flip0_seq);
145 | u8x8->x_offset = u8x8->display_info->default_x_offset;
146 | }
147 | else
148 | {
149 | u8x8_cad_SendSequence(u8x8, u8x8_d_uc1601_128x32_flip1_seq);
150 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
151 | }
152 | break;
153 | #ifdef U8X8_WITH_SET_CONTRAST
154 | case U8X8_MSG_DISPLAY_SET_CONTRAST:
155 | u8x8_cad_StartTransfer(u8x8);
156 | u8x8_cad_SendCmd(u8x8, 0x081 );
157 | u8x8_cad_SendArg(u8x8, arg_int ); /* uc1601 has range from 0 to 255 */
158 | u8x8_cad_EndTransfer(u8x8);
159 | break;
160 | #endif
161 | case U8X8_MSG_DISPLAY_DRAW_TILE:
162 | u8x8_cad_StartTransfer(u8x8);
163 |
164 | x = ((u8x8_tile_t *)arg_ptr)->x_pos;
165 | x *= 8;
166 | x += u8x8->x_offset;
167 | u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
168 | u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
169 | u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
170 |
171 | c = ((u8x8_tile_t *)arg_ptr)->cnt;
172 | c *= 8;
173 | ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
174 | do
175 | {
176 | u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
177 | arg_int--;
178 | } while( arg_int > 0 );
179 |
180 | u8x8_cad_EndTransfer(u8x8);
181 | break;
182 | default:
183 | return 0;
184 | }
185 | return 1;
186 | }
187 |
188 |
189 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8x8_d_uc1638.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8x8_d_uc1638.c
4 |
5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6 |
7 | Copyright (c) 2016, 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 "u8x8.h"
38 |
39 |
40 |
41 |
42 |
43 | static const uint8_t u8x8_d_uc1638_powersave0_seq[] = {
44 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
45 | U8X8_CA(0x0c9, 0x0ad), /* display on */ /* UC1638 B/W mode */
46 | U8X8_END_TRANSFER(), /* disable chip */
47 | U8X8_END() /* end of sequence */
48 | };
49 |
50 | static const uint8_t u8x8_d_uc1638_powersave1_seq[] = {
51 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
52 | U8X8_CA(0x0c9, 0x0ac), /* display off */ /* UC1638 */
53 | U8X8_END_TRANSFER(), /* disable chip */
54 | U8X8_END() /* end of sequence */
55 | };
56 |
57 | static const uint8_t u8x8_d_uc1638_flip0_seq[] = {
58 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
59 | U8X8_C(0x0c4), /* LCD Mapping */ /* UC1638*/
60 | U8X8_END_TRANSFER(), /* disable chip */
61 | U8X8_END() /* end of sequence */
62 | };
63 |
64 | static const uint8_t u8x8_d_uc1638_flip1_seq[] = {
65 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
66 | U8X8_C(0x0c2), /* LCD Mapping */ /* UC1638*/
67 | U8X8_END_TRANSFER(), /* disable chip */
68 | U8X8_END() /* end of sequence */
69 | };
70 |
71 |
72 | uint8_t u8x8_d_uc1638_common(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
73 | {
74 | uint8_t x, y, c;
75 | uint8_t *ptr;
76 | switch(msg)
77 | {
78 | case U8X8_MSG_DISPLAY_DRAW_TILE:
79 | u8x8_cad_StartTransfer(u8x8);
80 |
81 | x = ((u8x8_tile_t *)arg_ptr)->x_pos;
82 | x *= 8;
83 |
84 | u8x8_cad_SendCmd(u8x8, 0x004); /* UC1638 */
85 | u8x8_cad_SendArg(u8x8, x);
86 |
87 | y = ((u8x8_tile_t *)arg_ptr)->y_pos;
88 | y += u8x8->x_offset;
89 | y *= 2; /* for B/W mode, use only every second page */
90 |
91 | u8x8_cad_SendCmd(u8x8, 0x060 | (y&15)); /* UC1638 */
92 | u8x8_cad_SendCmd(u8x8, 0x070 | (y>>4)); /* UC1638 */
93 |
94 |
95 | u8x8_cad_SendCmd(u8x8, 0x001); /* UC1638 */
96 | c = ((u8x8_tile_t *)arg_ptr)->cnt;
97 | c *= 8;
98 | ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
99 | do
100 | {
101 | u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
102 | arg_int--;
103 | } while( arg_int > 0 );
104 |
105 | u8x8_cad_EndTransfer(u8x8);
106 | break;
107 | /* handled in the calling procedure
108 | case U8X8_MSG_DISPLAY_SETUP_MEMORY:
109 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1638_128x64_display_info);
110 | break;
111 | case U8X8_MSG_DISPLAY_INIT:
112 | u8x8_d_helper_display_init(u8x8);
113 | u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_init_seq);
114 | break;
115 | */
116 | case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
117 | if ( arg_int == 0 )
118 | u8x8_cad_SendSequence(u8x8, u8x8_d_uc1638_powersave0_seq);
119 | else
120 | u8x8_cad_SendSequence(u8x8, u8x8_d_uc1638_powersave1_seq);
121 | break;
122 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
123 | if ( arg_int == 0 )
124 | {
125 | u8x8_cad_SendSequence(u8x8, u8x8_d_uc1638_flip0_seq);
126 | u8x8->x_offset = u8x8->display_info->default_x_offset;
127 | }
128 | else
129 | {
130 | u8x8_cad_SendSequence(u8x8, u8x8_d_uc1638_flip1_seq);
131 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
132 | }
133 | break;
134 | #ifdef U8X8_WITH_SET_CONTRAST
135 | case U8X8_MSG_DISPLAY_SET_CONTRAST:
136 | u8x8_cad_StartTransfer(u8x8);
137 | u8x8_cad_SendCmd(u8x8, 0x081 );
138 | u8x8_cad_SendArg(u8x8, arg_int ); /* uc1638 has range from 0 to 255 */
139 | u8x8_cad_EndTransfer(u8x8);
140 | break;
141 | #endif
142 | default:
143 | return 0;
144 | }
145 | return 1;
146 | }
147 |
148 |
149 | /*================================================*/
150 | /* uc1638 160x128 */
151 |
152 | /* values taken from uc1608 */
153 | static const u8x8_display_info_t u8x8_uc1638_160x128_display_info =
154 | {
155 | /* chip_enable_level = */ 1, /* uc1638 has high active CS */
156 | /* chip_disable_level = */ 0,
157 |
158 | /* post_chip_enable_wait_ns = */ 10, /* */
159 | /* pre_chip_disable_wait_ns = */ 20, /* */
160 | /* reset_pulse_width_ms = */ 5, /* */
161 | /* post_reset_wait_ms = */ 150,
162 | /* sda_setup_time_ns = */ 30, /* */
163 | /* sck_pulse_width_ns = */ 65, /* */
164 | /* sck_clock_hz = */ 1000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
165 | /* spi_mode = */ 3, /* active high, rising edge */
166 | /* i2c_bus_clock_100kHz = */ 4,
167 | /* data_setup_time_ns = */ 30, /* */
168 | /* write_pulse_width_ns = */ 35, /* */
169 | /* tile_width = */ 20, /* width of 20*8=160 pixel */
170 | /* tile_hight = */ 16,
171 | /* default_x_offset = */ 0, /* */
172 | /* flipmode_x_offset = */ 0, /* */
173 | /* pixel_width = */ 160,
174 | /* pixel_height = */ 128
175 | };
176 |
177 | static const uint8_t u8x8_d_uc1638_160x128_init_seq[] = {
178 |
179 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
180 |
181 | U8X8_CA(0x0e1, 0x0e2), /* software reset */ /* UC1638*/
182 | U8X8_DLY(5), /* 5 ms */
183 |
184 | U8X8_C(0x024), /* set temp comp*/
185 | U8X8_C(0x0c0), /* mirror y and mirror x */ /* WAS: c2 */
186 | U8X8_C(0x0a2), /* line rate */
187 | U8X8_C(0x0d6), /* gray scale 2 */
188 | U8X8_C(0x0eb), /* set bias*/
189 | U8X8_C(0x095), /* set 1 bit per pixel, pattern 0*/
190 | U8X8_C(0x089), /* set auto increment, low bits are AC2 AC1 AC0 */ /* WAS 89 */
191 |
192 |
193 | U8X8_CA(0x081, 0x0a0), /* set contrast */ /* UC1638*/
194 |
195 |
196 | U8X8_END_TRANSFER(), /* disable chip */
197 | U8X8_END() /* end of sequence */
198 | };
199 |
200 | uint8_t u8x8_d_uc1638_160x128(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
201 | {
202 | /* call common procedure first and handle messages there */
203 | if ( u8x8_d_uc1638_common(u8x8, msg, arg_int, arg_ptr) == 0 )
204 | {
205 | /* msg not handled, then try here */
206 | switch(msg)
207 | {
208 | case U8X8_MSG_DISPLAY_SETUP_MEMORY:
209 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1638_160x128_display_info);
210 | break;
211 | case U8X8_MSG_DISPLAY_INIT:
212 | u8x8_d_helper_display_init(u8x8);
213 | u8x8_cad_SendSequence(u8x8, u8x8_d_uc1638_160x128_init_seq);
214 | break;
215 | default:
216 | return 0; /* msg unknown */
217 | }
218 | }
219 | return 1;
220 | }
221 |
222 |
223 | /*================================================*/
224 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8x8_d_uc1701_dogs102.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8x8_d_uc1701_dogs102.c
4 |
5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6 |
7 | Copyright (c) 2016, olikraus@gmail.com
8 | All rights reserved.
9 |
10 | Redistribution and use in source and binary forms, with or without modification,
11 | are permitted provided that the following conditions are met:
12 |
13 | * Redistributions of source code must retain the above copyright notice, this list
14 | of conditions and the following disclaimer.
15 |
16 | * Redistributions in binary form must reproduce the above copyright notice, this
17 | list of conditions and the following disclaimer in the documentation and/or other
18 | materials provided with the distribution.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
21 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 |
34 |
35 | */
36 | #include "u8x8.h"
37 |
38 |
39 |
40 |
41 | static const uint8_t u8x8_d_uc1701_dogs102_init_seq[] = {
42 |
43 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
44 |
45 | U8X8_C(0x0e2), /* soft reset */
46 | U8X8_C(0x0ae), /* display off */
47 | U8X8_C(0x040), /* set display start line to 0 */
48 |
49 | U8X8_C(0x0a1), /* ADC set to reverse */
50 | U8X8_C(0x0c0), /* common output mode */
51 | // Flipmode
52 | //U8X8_C(0x0a0), /* ADC set to reverse */
53 | //U8X8_C(0x0c8), /* common output mode */
54 |
55 | U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */
56 | U8X8_C(0x0a2), /* LCD bias 1/9 */
57 | U8X8_C(0x02f), /* all power control circuits on */
58 | U8X8_C(0x027), /* regulator, booster and follower */
59 | U8X8_CA(0x081, 0x00e), /* set contrast, contrast value, EA default: 0x010, previous value for S102: 0x0e */
60 | U8X8_C(0x0fa), /* Set Temp compensation */
61 | U8X8_C(0x090), /* 0.11 deg/c WP Off WC Off*/
62 |
63 | U8X8_C(0x0ae), /* display off */
64 | U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */
65 |
66 | U8X8_END_TRANSFER(), /* disable chip */
67 | U8X8_END() /* end of sequence */
68 | };
69 |
70 | static const uint8_t u8x8_d_uc1701_dogs102_powersave0_seq[] = {
71 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
72 | U8X8_C(0x0a4), /* all pixel off, issue 142 */
73 | U8X8_C(0x0af), /* display on */
74 | U8X8_END_TRANSFER(), /* disable chip */
75 | U8X8_END() /* end of sequence */
76 | };
77 |
78 | static const uint8_t u8x8_d_uc1701_dogs102_powersave1_seq[] = {
79 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
80 | U8X8_C(0x0ae), /* display off */
81 | U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */
82 | U8X8_END_TRANSFER(), /* disable chip */
83 | U8X8_END() /* end of sequence */
84 | };
85 |
86 | static const uint8_t u8x8_d_uc1701_dogs102_flip0_seq[] = {
87 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
88 | U8X8_C(0x0a1), /* segment remap a0/a1*/
89 | U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
90 | U8X8_END_TRANSFER(), /* disable chip */
91 | U8X8_END() /* end of sequence */
92 | };
93 |
94 | static const uint8_t u8x8_d_uc1701_dogs102_flip1_seq[] = {
95 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
96 | U8X8_C(0x0a0), /* segment remap a0/a1*/
97 | U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
98 | U8X8_END_TRANSFER(), /* disable chip */
99 | U8X8_END() /* end of sequence */
100 | };
101 |
102 |
103 | static const u8x8_display_info_t u8x8_uc1701_display_info =
104 | {
105 | /* chip_enable_level = */ 0,
106 | /* chip_disable_level = */ 1,
107 |
108 | /* post_chip_enable_wait_ns = */ 5,
109 | /* pre_chip_disable_wait_ns = */ 5,
110 | /* reset_pulse_width_ms = */ 1,
111 | /* post_reset_wait_ms = */ 6,
112 | /* sda_setup_time_ns = */ 12,
113 | /* sck_pulse_width_ns = */ 75, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
114 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
115 | /* spi_mode = */ 0, /* active high, rising edge */
116 | /* i2c_bus_clock_100kHz = */ 4,
117 | /* data_setup_time_ns = */ 30,
118 | /* write_pulse_width_ns = */ 40,
119 | /* tile_width = */ 13, /* width of 13*8=104 pixel */
120 | /* tile_hight = */ 8,
121 | /* default_x_offset = */ 0,
122 | /* flipmode_x_offset = */ 30,
123 | /* pixel_width = */ 102,
124 | /* pixel_height = */ 64
125 | };
126 |
127 | uint8_t u8x8_d_uc1701_ea_dogs102(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
128 | {
129 | uint8_t x, c;
130 | uint8_t *ptr;
131 | switch(msg)
132 | {
133 | case U8X8_MSG_DISPLAY_SETUP_MEMORY:
134 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1701_display_info);
135 | break;
136 | case U8X8_MSG_DISPLAY_INIT:
137 | u8x8_d_helper_display_init(u8x8);
138 | u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_init_seq);
139 | break;
140 | case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
141 | if ( arg_int == 0 )
142 | u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_powersave0_seq);
143 | else
144 | u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_powersave1_seq);
145 | break;
146 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
147 | if ( arg_int == 0 )
148 | {
149 | u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_flip0_seq);
150 | u8x8->x_offset = u8x8->display_info->default_x_offset;
151 | }
152 | else
153 | {
154 | u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_dogs102_flip1_seq);
155 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
156 | }
157 | break;
158 | #ifdef U8X8_WITH_SET_CONTRAST
159 | case U8X8_MSG_DISPLAY_SET_CONTRAST:
160 | u8x8_cad_StartTransfer(u8x8);
161 | u8x8_cad_SendCmd(u8x8, 0x081 );
162 | u8x8_cad_SendArg(u8x8, arg_int >> 2 ); /* uc1701 has range from 0 to 63 */
163 | u8x8_cad_EndTransfer(u8x8);
164 | break;
165 | #endif
166 | case U8X8_MSG_DISPLAY_DRAW_TILE:
167 | u8x8_cad_StartTransfer(u8x8);
168 |
169 | x = ((u8x8_tile_t *)arg_ptr)->x_pos;
170 | x *= 8;
171 | x += u8x8->x_offset;
172 | u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
173 | u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
174 | u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
175 |
176 | c = ((u8x8_tile_t *)arg_ptr)->cnt;
177 | c *= 8;
178 | ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
179 | /*
180 | The following if condition checks the hardware limits of the uc1701
181 | controller: It is not allowed to write beyond the display limits.
182 | This is in fact an issue within flip mode.
183 | */
184 | if ( c + x > 132u )
185 | {
186 | c = 132u;
187 | c -= x;
188 | }
189 | do
190 | {
191 | u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
192 | arg_int--;
193 | } while( arg_int > 0 );
194 |
195 | u8x8_cad_EndTransfer(u8x8);
196 | break;
197 | default:
198 | return 0;
199 | }
200 | return 1;
201 | }
202 |
203 |
204 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8x8_d_uc1701_mini12864.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8x8_d_uc1701_mini12864.c (dealextreme, displays from ebay MP3 players)
4 |
5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6 |
7 | Copyright (c) 2016, olikraus@gmail.com
8 | All rights reserved.
9 |
10 | Redistribution and use in source and binary forms, with or without modification,
11 | are permitted provided that the following conditions are met:
12 |
13 | * Redistributions of source code must retain the above copyright notice, this list
14 | of conditions and the following disclaimer.
15 |
16 | * Redistributions in binary form must reproduce the above copyright notice, this
17 | list of conditions and the following disclaimer in the documentation and/or other
18 | materials provided with the distribution.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
21 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 |
34 |
35 | */
36 | #include "u8x8.h"
37 |
38 |
39 |
40 |
41 | static const uint8_t u8x8_d_uc1701_mini12864_init_seq[] = {
42 |
43 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
44 |
45 | U8X8_C(0x0e2), /* soft reset */
46 | U8X8_C(0x0ae), /* display off */
47 | U8X8_C(0x040), /* set display start line to 0 */
48 |
49 | U8X8_C(0x0a0), /* ADC set to reverse */
50 | U8X8_C(0x0c8), /* common output mode */
51 |
52 | U8X8_C(0x0a6), /* display normal, bit val 0: LCD pixel off. */
53 | U8X8_C(0x0a2), /* LCD bias 1/9 */
54 | U8X8_C(0x02f), /* all power control circuits on */
55 | U8X8_C(0x0f8), /* set booster ratio to */
56 | U8X8_C(0x000), /* 4x */
57 | U8X8_C(0x023), /* set V0 voltage resistor ratio to large */
58 | U8X8_C(0x081), /* set contrast */
59 | U8X8_C(0x027), /* contrast value */
60 | U8X8_C(0x0ac), /* indicator */
61 | // 0x000, /* disable */
62 |
63 | U8X8_C(0x0ae), /* display off */
64 | U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */
65 |
66 | U8X8_END_TRANSFER(), /* disable chip */
67 | U8X8_END() /* end of sequence */
68 | };
69 |
70 | static const uint8_t u8x8_d_uc1701_mini12864_powersave0_seq[] = {
71 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
72 | U8X8_C(0x0a4), /* all pixel off, issue 142 */
73 | U8X8_C(0x0af), /* display on */
74 | U8X8_END_TRANSFER(), /* disable chip */
75 | U8X8_END() /* end of sequence */
76 | };
77 |
78 | static const uint8_t u8x8_d_uc1701_mini12864_powersave1_seq[] = {
79 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
80 | U8X8_C(0x0ae), /* display off */
81 | U8X8_C(0x0a5), /* enter powersafe: all pixel on, issue 142 */
82 | U8X8_END_TRANSFER(), /* disable chip */
83 | U8X8_END() /* end of sequence */
84 | };
85 |
86 | static const uint8_t u8x8_d_uc1701_mini12864_flip0_seq[] = {
87 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
88 | U8X8_C(0x0a0), /* segment remap a0/a1*/
89 | U8X8_C(0x0c8), /* c0: scan dir normal, c8: reverse */
90 | U8X8_END_TRANSFER(), /* disable chip */
91 | U8X8_END() /* end of sequence */
92 | };
93 |
94 | static const uint8_t u8x8_d_uc1701_mini12864_flip1_seq[] = {
95 | U8X8_START_TRANSFER(), /* enable chip, delay is part of the transfer start */
96 | U8X8_C(0x0a1), /* segment remap a0/a1*/
97 | U8X8_C(0x0c0), /* c0: scan dir normal, c8: reverse */
98 | U8X8_END_TRANSFER(), /* disable chip */
99 | U8X8_END() /* end of sequence */
100 | };
101 |
102 |
103 | static const u8x8_display_info_t u8x8_uc1701_display_info =
104 | {
105 | /* chip_enable_level = */ 0,
106 | /* chip_disable_level = */ 1,
107 |
108 | /* post_chip_enable_wait_ns = */ 5,
109 | /* pre_chip_disable_wait_ns = */ 5,
110 | /* reset_pulse_width_ms = */ 1,
111 | /* post_reset_wait_ms = */ 6,
112 | /* sda_setup_time_ns = */ 12,
113 | /* sck_pulse_width_ns = */ 75, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
114 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
115 | /* spi_mode = */ 0, /* active high, rising edge */
116 | /* i2c_bus_clock_100kHz = */ 4,
117 | /* data_setup_time_ns = */ 30,
118 | /* write_pulse_width_ns = */ 40,
119 | /* tile_width = */ 16, /* width of 16*8=128 pixel */
120 | /* tile_hight = */ 8,
121 | /* default_x_offset = */ 0,
122 | /* flipmode_x_offset = */ 4,
123 | /* pixel_width = */ 128,
124 | /* pixel_height = */ 64
125 | };
126 |
127 | uint8_t u8x8_d_uc1701_mini12864(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr)
128 | {
129 | uint8_t x, c;
130 | uint8_t *ptr;
131 | switch(msg)
132 | {
133 | case U8X8_MSG_DISPLAY_SETUP_MEMORY:
134 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_uc1701_display_info);
135 | break;
136 | case U8X8_MSG_DISPLAY_INIT:
137 | u8x8_d_helper_display_init(u8x8);
138 | u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_mini12864_init_seq);
139 | break;
140 | case U8X8_MSG_DISPLAY_SET_POWER_SAVE:
141 | if ( arg_int == 0 )
142 | u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_mini12864_powersave0_seq);
143 | else
144 | u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_mini12864_powersave1_seq);
145 | break;
146 | case U8X8_MSG_DISPLAY_SET_FLIP_MODE:
147 | if ( arg_int == 0 )
148 | {
149 | u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_mini12864_flip0_seq);
150 | u8x8->x_offset = u8x8->display_info->default_x_offset;
151 | }
152 | else
153 | {
154 | u8x8_cad_SendSequence(u8x8, u8x8_d_uc1701_mini12864_flip1_seq);
155 | u8x8->x_offset = u8x8->display_info->flipmode_x_offset;
156 | }
157 | break;
158 | #ifdef U8X8_WITH_SET_CONTRAST
159 | case U8X8_MSG_DISPLAY_SET_CONTRAST:
160 | u8x8_cad_StartTransfer(u8x8);
161 | u8x8_cad_SendCmd(u8x8, 0x081 );
162 | u8x8_cad_SendArg(u8x8, arg_int >> 2 ); /* uc1701 has range from 0 to 63 */
163 | u8x8_cad_EndTransfer(u8x8);
164 | break;
165 | #endif
166 | case U8X8_MSG_DISPLAY_DRAW_TILE:
167 | u8x8_cad_StartTransfer(u8x8);
168 |
169 | x = ((u8x8_tile_t *)arg_ptr)->x_pos;
170 | x *= 8;
171 | x += u8x8->x_offset;
172 | u8x8_cad_SendCmd(u8x8, 0x010 | (x>>4) );
173 | u8x8_cad_SendCmd(u8x8, 0x000 | ((x&15)));
174 | u8x8_cad_SendCmd(u8x8, 0x0b0 | (((u8x8_tile_t *)arg_ptr)->y_pos));
175 |
176 | c = ((u8x8_tile_t *)arg_ptr)->cnt;
177 | c *= 8;
178 | ptr = ((u8x8_tile_t *)arg_ptr)->tile_ptr;
179 | /*
180 | The following if condition checks the hardware limits of the uc1701
181 | controller: It is not allowed to write beyond the display limits.
182 | This is in fact an issue within flip mode.
183 |
184 | bug: this check should be inside the while loop, see u8x8_d_pcd8544_84x48.c
185 | */
186 | if ( c + x > 132u )
187 | {
188 | c = 132u;
189 | c -= x;
190 | }
191 | do
192 | {
193 | u8x8_cad_SendData(u8x8, c, ptr); /* note: SendData can not handle more than 255 bytes */
194 | arg_int--;
195 | } while( arg_int > 0 );
196 |
197 | u8x8_cad_EndTransfer(u8x8);
198 | break;
199 | default:
200 | return 0;
201 | }
202 | return 1;
203 | }
204 |
205 |
206 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8x8_debounce.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8x8_debounce.c
4 |
5 | Key/button simple debounce algorithm (Addon for u8x8)
6 |
7 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
8 |
9 | Copyright (c) 2016, 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 "u8x8.h"
39 |
40 | static uint8_t u8x8_read_pin_state(u8x8_t *u8x8)
41 | {
42 | uint8_t i;
43 | uint8_t pin_state;
44 |
45 | pin_state = 255; /* be compatible with the setup of the default pin setup, which is 255 */
46 | for( i = 0; i < U8X8_PIN_INPUT_CNT; i++ )
47 | {
48 | pin_state <<= 1;
49 |
50 | /* the callback function should put the return value into this variable */
51 | u8x8->gpio_result = 1;
52 | u8x8_gpio_call(u8x8, U8X8_MSG_GPIO(i+U8X8_PIN_OUTPUT_CNT), 0);
53 | pin_state |= u8x8->gpio_result & 1;
54 | }
55 |
56 | return pin_state;
57 | }
58 |
59 | /*
60 | return 0 to U8X8_PIN_INPUT_CNT-1 if there is a difference
61 | return U8X8_PIN_INPUT_CNT if there is no difference
62 | */
63 | static uint8_t u8x8_find_first_diff(uint8_t a, uint8_t b)
64 | {
65 | uint8_t mask;
66 | uint8_t i;
67 | mask = 1;
68 | i = U8X8_PIN_INPUT_CNT;
69 | do
70 | {
71 | i--;
72 | if ( (a & mask) != (b & mask) )
73 | return i;
74 | mask <<= 1;
75 | } while( i > 0 );
76 | return U8X8_PIN_INPUT_CNT;
77 | }
78 |
79 | /*
80 | State A:
81 | u8x8->debounce_last_pin_state == current_state
82 | --> State A
83 | u8x8->debounce_last_pin_state != current_state
84 | --> u8x8->debounce_last_pin_state = current_state
85 | --> State B + cnt
86 |
87 | State B + cnt
88 | --> state--
89 |
90 | State B
91 | u8x8->debounce_last_pin_state == current_state
92 | --> keypress detected
93 | --> State C
94 | u8x8->debounce_last_pin_state != current_state
95 | --> State A
96 |
97 | State C
98 | u8x8->debounce_last_pin_state == current_state
99 | --> State C
100 | u8x8->debounce_last_pin_state != current_state
101 | --> State A
102 |
103 | */
104 |
105 | #ifdef __unix__xxxxxx_THIS_IS_DISABLED
106 |
107 | #include
108 | #include
109 | uint8_t u8x8_GetMenuEvent(u8x8_t *u8x8)
110 | {
111 | int c;
112 | c = getc(stdin);
113 | switch(c)
114 | {
115 | case 'n':
116 | return U8X8_MSG_GPIO_MENU_NEXT;
117 | case 'p':
118 | return U8X8_MSG_GPIO_MENU_PREV;
119 | case 's':
120 | return U8X8_MSG_GPIO_MENU_SELECT;
121 | case 'h':
122 | return U8X8_MSG_GPIO_MENU_HOME;
123 | case 'x':
124 | exit(0);
125 | default:
126 | puts("press n, p, s, h or x");
127 | break;
128 | }
129 | return 0;
130 | }
131 |
132 |
133 | #else /* __unix__ */
134 |
135 |
136 | #define U8X8_DEBOUNCE_WAIT 2
137 | /* do debounce and return a GPIO msg which indicates the event */
138 | /* returns 0, if there is no event */
139 | #if defined(__GNUC__) && !defined(__CYGWIN__)
140 | # pragma weak u8x8_GetMenuEvent
141 | #endif
142 | uint8_t u8x8_GetMenuEvent(u8x8_t *u8x8)
143 | {
144 | uint8_t pin_state;
145 | uint8_t result_msg = 0; /* invalid message, no event */
146 |
147 | pin_state = u8x8_read_pin_state(u8x8);
148 |
149 | /* States A, B, C & D are encoded in the upper 4 bit*/
150 | switch(u8x8->debounce_state)
151 | {
152 | case 0x00: /* State A, default state */
153 | if ( u8x8->debounce_default_pin_state != pin_state )
154 | {
155 | //u8x8->debounce_last_pin_state = pin_state;
156 | u8x8->debounce_state = 0x010 + U8X8_DEBOUNCE_WAIT;
157 | }
158 | break;
159 | case 0x10: /* State B */
160 | //if ( u8x8->debounce_last_pin_state != pin_state )
161 | if ( u8x8->debounce_default_pin_state == pin_state )
162 | {
163 | u8x8->debounce_state = 0x00; /* back to state A */
164 | }
165 | else
166 | {
167 | /* keypress detected */
168 | u8x8->debounce_last_pin_state = pin_state;
169 | //result_msg = U8X8_MSG_GPIO_MENU_NEXT;
170 | u8x8->debounce_state = 0x020 + U8X8_DEBOUNCE_WAIT; /* got to state C */
171 | }
172 | break;
173 |
174 | case 0x20: /* State C */
175 | if ( u8x8->debounce_last_pin_state != pin_state )
176 | {
177 | u8x8->debounce_state = 0x00; /* back to state A */
178 | }
179 | else
180 | {
181 | u8x8->debounce_state = 0x030; /* got to state D */
182 | }
183 | break;
184 |
185 | case 0x30: /* State D */
186 | /* wait until key release */
187 | if ( u8x8->debounce_default_pin_state == pin_state )
188 | {
189 | u8x8->debounce_state = 0x00; /* back to state A */
190 | result_msg = U8X8_MSG_GPIO(u8x8_find_first_diff(u8x8->debounce_default_pin_state, u8x8->debounce_last_pin_state)+U8X8_PIN_OUTPUT_CNT);
191 | }
192 | else
193 | {
194 | //result_msg = U8X8_MSG_GPIO_MENU_NEXT;
195 | // maybe implement autorepeat here
196 | }
197 | break;
198 | default:
199 | u8x8->debounce_state--; /* count down, until there is a valid state */
200 | break;
201 | }
202 | return result_msg;
203 | }
204 |
205 | #endif /* __unix__ */
206 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8x8_display.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8x8_display.c
4 |
5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6 |
7 | Copyright (c) 2016, 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 | Abstraction layer for the graphics controller.
36 | Main goal is the placement of a 8x8 pixel block (tile) on the display.
37 |
38 | */
39 |
40 |
41 | #include "u8x8.h"
42 |
43 |
44 | /*==========================================*/
45 | /* internal library function */
46 |
47 | /*
48 | this is a helper function for the U8X8_MSG_DISPLAY_SETUP_MEMORY function.
49 | It can be called within the display callback function to carry out the usual standard tasks.
50 |
51 | */
52 | void u8x8_d_helper_display_setup_memory(u8x8_t *u8x8, const u8x8_display_info_t *display_info)
53 | {
54 | /* 1) set display info struct */
55 | u8x8->display_info = display_info;
56 | u8x8->x_offset = u8x8->display_info->default_x_offset;
57 | }
58 |
59 | /*
60 | this is a helper function for the U8X8_MSG_DISPLAY_INIT function.
61 | It can be called within the display callback function to carry out the usual standard tasks.
62 |
63 | */
64 | void u8x8_d_helper_display_init(u8x8_t *u8x8)
65 | {
66 | /* 2) apply port directions to the GPIO lines and apply default values for the IO lines*/
67 | u8x8_gpio_Init(u8x8);
68 | u8x8_cad_Init(u8x8);
69 |
70 | /* 3) do reset */
71 | u8x8_gpio_SetReset(u8x8, 1);
72 | u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_MILLI, u8x8->display_info->reset_pulse_width_ms);
73 | u8x8_gpio_SetReset(u8x8, 0);
74 | u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_MILLI, u8x8->display_info->reset_pulse_width_ms);
75 | u8x8_gpio_SetReset(u8x8, 1);
76 | u8x8_gpio_Delay(u8x8, U8X8_MSG_DELAY_MILLI, u8x8->display_info->post_reset_wait_ms);
77 | }
78 |
79 | /*==========================================*/
80 | /* official functions */
81 |
82 | uint8_t u8x8_DrawTile(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t cnt, uint8_t *tile_ptr)
83 | {
84 | u8x8_tile_t tile;
85 | tile.x_pos = x;
86 | tile.y_pos = y;
87 | tile.cnt = cnt;
88 | tile.tile_ptr = tile_ptr;
89 | return u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_DRAW_TILE, 1, (void *)&tile);
90 | }
91 |
92 | /* should be implemented as macro */
93 | void u8x8_SetupMemory(u8x8_t *u8x8)
94 | {
95 | u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SETUP_MEMORY, 0, NULL);
96 | }
97 |
98 | void u8x8_InitDisplay(u8x8_t *u8x8)
99 | {
100 | u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_INIT, 0, NULL);
101 | }
102 |
103 | void u8x8_SetPowerSave(u8x8_t *u8x8, uint8_t is_enable)
104 | {
105 | u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SET_POWER_SAVE, is_enable, NULL);
106 | }
107 |
108 | void u8x8_SetFlipMode(u8x8_t *u8x8, uint8_t mode)
109 | {
110 | u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SET_FLIP_MODE, mode, NULL);
111 | }
112 |
113 | void u8x8_SetContrast(u8x8_t *u8x8, uint8_t value)
114 | {
115 | u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_SET_CONTRAST, value, NULL);
116 | }
117 |
118 | void u8x8_RefreshDisplay(u8x8_t *u8x8)
119 | {
120 | u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_REFRESH, 0, NULL);
121 | }
122 |
123 | void u8x8_ClearDisplayWithTile(u8x8_t *u8x8, const uint8_t *buf)
124 | {
125 | u8x8_tile_t tile;
126 | uint8_t h;
127 |
128 | tile.x_pos = 0;
129 | tile.cnt = 1;
130 | tile.tile_ptr = (uint8_t *)buf; /* tile_ptr should be const, but isn't */
131 |
132 | h = u8x8->display_info->tile_height;
133 | tile.y_pos = 0;
134 | do
135 | {
136 | u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_DRAW_TILE, u8x8->display_info->tile_width, (void *)&tile);
137 | tile.y_pos++;
138 | } while( tile.y_pos < h );
139 | }
140 |
141 | void u8x8_ClearDisplay(u8x8_t *u8x8)
142 | {
143 | uint8_t buf[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
144 | u8x8_ClearDisplayWithTile(u8x8, buf);
145 | }
146 |
147 | void u8x8_FillDisplay(u8x8_t *u8x8)
148 | {
149 | uint8_t buf[8] = { 255, 255, 255, 255, 255, 255, 255, 255 };
150 | u8x8_ClearDisplayWithTile(u8x8, buf);
151 | }
152 |
153 | void u8x8_ClearLine(u8x8_t *u8x8, uint8_t line)
154 | {
155 | uint8_t buf[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
156 | u8x8_tile_t tile;
157 | if ( line < u8x8->display_info->tile_height )
158 | {
159 | tile.x_pos = 0;
160 | tile.y_pos = line;
161 | tile.cnt = 1;
162 | tile.tile_ptr = (uint8_t *)buf; /* tile_ptr should be const, but isn't */
163 | u8x8->display_cb(u8x8, U8X8_MSG_DISPLAY_DRAW_TILE, u8x8->display_info->tile_width, (void *)&tile);
164 | }
165 | }
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8x8_fonts.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lyusupov/POST_S76G/9f51ff1edaf0adfae1e6cb3535eadefa8c421b45/libraries/U8g2/src/clib/u8x8_fonts.c
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8x8_gpio.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8x8_gpio.c
4 |
5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6 |
7 | Copyright (c) 2016, 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 "u8x8.h"
38 |
39 |
40 | void u8x8_gpio_call(u8x8_t *u8x8, uint8_t msg, uint8_t arg)
41 | {
42 | u8x8->gpio_and_delay_cb(u8x8, msg, arg, NULL);
43 | }
44 |
45 | /*
46 | void u8x8_gpio_Delay(u8x8_t *u8x8, uint8_t msg, uint8_t dly)
47 | {
48 | u8x8->gpio_and_delay_cb(u8x8, msg, dly, NULL);
49 | }
50 | */
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8x8_input_value.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8x8_input_value.c
4 |
5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6 |
7 | Copyright (c) 2016, olikraus@gmail.com
8 | All rights reserved.
9 |
10 | Redistribution and use in source and binary forms, with or without modification,
11 | are permitted provided that the following conditions are met:
12 |
13 | * Redistributions of source code must retain the above copyright notice, this list
14 | of conditions and the following disclaimer.
15 |
16 | * Redistributions in binary form must reproduce the above copyright notice, this
17 | list of conditions and the following disclaimer in the documentation and/or other
18 | materials provided with the distribution.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
21 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 |
34 | */
35 |
36 | #include "u8x8.h"
37 |
38 | /*
39 | return:
40 | 0: value is not changed (HOME/Break Button pressed)
41 | 1: value has been updated
42 | */
43 |
44 | uint8_t u8x8_UserInterfaceInputValue(u8x8_t *u8x8, const char *title, const char *pre, uint8_t *value, uint8_t lo, uint8_t hi, uint8_t digits, const char *post)
45 | {
46 | uint8_t height;
47 | uint8_t y;
48 | uint8_t width;
49 | uint8_t x;
50 | uint8_t local_value = *value;
51 | uint8_t r;
52 | uint8_t event;
53 |
54 | /* calculate overall height of the input value box */
55 | height = 1; /* button line */
56 | height += u8x8_GetStringLineCnt(title);
57 |
58 | /* calculate offset from top */
59 | y = 0;
60 | if ( height < u8x8_GetRows(u8x8) )
61 | {
62 | y = u8x8_GetRows(u8x8);
63 | y -= height;
64 | y /= 2;
65 | }
66 |
67 | /* calculate offset from left for the label */
68 | x = 0;
69 | width = u8x8_GetUTF8Len(u8x8, pre);
70 | width += digits;
71 | width += u8x8_GetUTF8Len(u8x8, post);
72 | if ( width < u8x8_GetCols(u8x8) )
73 | {
74 | x = u8x8_GetCols(u8x8);
75 | x -= width;
76 | x /= 2;
77 | }
78 |
79 | /* render */
80 | u8x8_ClearDisplay(u8x8); /* required, because not everything is filled */
81 | u8x8_SetInverseFont(u8x8, 0);
82 | y += u8x8_DrawUTF8Lines(u8x8, 0, y, u8x8_GetCols(u8x8), title);
83 | x += u8x8_DrawUTF8(u8x8, x, y, pre);
84 | u8x8_DrawUTF8(u8x8, x+digits, y, post);
85 | u8x8_SetInverseFont(u8x8, 1);
86 |
87 | /* event loop */
88 | u8x8_DrawUTF8(u8x8, x, y, u8x8_u8toa(local_value, digits));
89 | for(;;)
90 | {
91 | event = u8x8_GetMenuEvent(u8x8);
92 | if ( event == U8X8_MSG_GPIO_MENU_SELECT )
93 | {
94 | *value = local_value;
95 | r = 1;
96 | break;
97 | }
98 | else if ( event == U8X8_MSG_GPIO_MENU_HOME )
99 | {
100 | r = 0;
101 | break;
102 | }
103 | else if ( event == U8X8_MSG_GPIO_MENU_NEXT || event == U8X8_MSG_GPIO_MENU_UP )
104 | {
105 | if ( local_value >= hi )
106 | local_value = lo;
107 | else
108 | local_value++;
109 | u8x8_DrawUTF8(u8x8, x, y, u8x8_u8toa(local_value, digits));
110 | }
111 | else if ( event == U8X8_MSG_GPIO_MENU_PREV || event == U8X8_MSG_GPIO_MENU_DOWN )
112 | {
113 | if ( local_value <= lo )
114 | local_value = hi;
115 | else
116 | local_value--;
117 | u8x8_DrawUTF8(u8x8, x, y, u8x8_u8toa(local_value, digits));
118 | }
119 | }
120 |
121 | u8x8_SetInverseFont(u8x8, 0);
122 | return r;
123 | }
124 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8x8_message.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8x8_message.c
4 |
5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6 |
7 | Copyright (c) 2016, olikraus@gmail.com
8 | All rights reserved.
9 |
10 | Redistribution and use in source and binary forms, with or without modification,
11 | are permitted provided that the following conditions are met:
12 |
13 | * Redistributions of source code must retain the above copyright notice, this list
14 | of conditions and the following disclaimer.
15 |
16 | * Redistributions in binary form must reproduce the above copyright notice, this
17 | list of conditions and the following disclaimer in the documentation and/or other
18 | materials provided with the distribution.
19 |
20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
21 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
22 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
30 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 |
34 | */
35 |
36 | #include "u8x8.h"
37 |
38 | uint8_t u8x8_draw_button_line(u8x8_t *u8x8, uint8_t y, uint8_t w, uint8_t cursor, const char *s)
39 | {
40 | uint8_t i;
41 | uint8_t cnt;
42 | uint8_t total;
43 | uint8_t d;
44 | uint8_t x;
45 | cnt = u8x8_GetStringLineCnt(s);
46 |
47 | /* calculate the width of the button */
48 | total = 0;
49 | for( i = 0; i < cnt; i++ )
50 | {
51 | total += u8x8_GetUTF8Len(u8x8, u8x8_GetStringLineStart(i, s));
52 | }
53 | total += (cnt-1); /* had one space between the buttons */
54 |
55 | /* calculate the left offset */
56 | d = 0;
57 | if ( total < w )
58 | {
59 | d = w;
60 | d -= total;
61 | d /= 2;
62 | }
63 |
64 | /* draw the buttons */
65 | x = d;
66 | u8x8_SetInverseFont(u8x8, 0);
67 | for( i = 0; i < cnt; i++ )
68 | {
69 | if ( i == cursor )
70 | u8x8_SetInverseFont(u8x8, 1);
71 |
72 | x+=u8x8_DrawUTF8(u8x8, x, y, u8x8_GetStringLineStart(i, s));
73 | u8x8_SetInverseFont(u8x8, 0);
74 | x+=u8x8_DrawUTF8(u8x8, x, y, " ");
75 | }
76 |
77 | /* return the number of buttons */
78 | return cnt;
79 | }
80 |
81 | /*
82 | title1: Multiple lines,separated by '\n'
83 | title2: A single line/string which is terminated by '\0' or '\n' . "title2" accepts the return value from u8x8_GetStringLineStart()
84 | title3: Multiple lines,separated by '\n'
85 | buttons: one more more buttons separated by '\n' and terminated with '\0'
86 | */
87 |
88 | uint8_t u8x8_UserInterfaceMessage(u8x8_t *u8x8, const char *title1, const char *title2, const char *title3, const char *buttons)
89 | {
90 | uint8_t height;
91 | uint8_t y;
92 | uint8_t cursor = 0;
93 | uint8_t button_cnt;
94 | uint8_t event;
95 |
96 | u8x8_SetInverseFont(u8x8, 0);
97 |
98 | /* calculate overall height of the message box */
99 | height = 1; /* button line */
100 | height += u8x8_GetStringLineCnt(title1);
101 | if ( title2 != NULL )
102 | height ++;
103 | height += u8x8_GetStringLineCnt(title3);
104 |
105 | /* calculate offset from top */
106 | y = 0;
107 | if ( height < u8x8_GetRows(u8x8) )
108 | {
109 | y = u8x8_GetRows(u8x8);
110 | y -= height;
111 | y /= 2;
112 | }
113 |
114 | /* draw message box */
115 |
116 | u8x8_ClearDisplay(u8x8); /* required, because not everything is filled */
117 |
118 | y += u8x8_DrawUTF8Lines(u8x8, 0, y, u8x8_GetCols(u8x8), title1);
119 | if ( title2 != NULL )
120 | {
121 | u8x8_DrawUTF8Line(u8x8, 0, y, u8x8_GetCols(u8x8), title2);
122 | y++;
123 | }
124 | y += u8x8_DrawUTF8Lines(u8x8, 0, y, u8x8_GetCols(u8x8), title3);
125 |
126 | button_cnt = u8x8_draw_button_line(u8x8, y, u8x8_GetCols(u8x8), cursor, buttons);
127 |
128 | for(;;)
129 | {
130 | event = u8x8_GetMenuEvent(u8x8);
131 | if ( event == U8X8_MSG_GPIO_MENU_SELECT )
132 | return cursor+1;
133 | else if ( event == U8X8_MSG_GPIO_MENU_HOME )
134 | break;
135 | else if ( event == U8X8_MSG_GPIO_MENU_NEXT || event == U8X8_MSG_GPIO_MENU_UP )
136 | {
137 | cursor++;
138 | if ( cursor >= button_cnt )
139 | cursor = 0;
140 | u8x8_draw_button_line(u8x8, y, u8x8_GetCols(u8x8), cursor, buttons);
141 | }
142 | else if ( event == U8X8_MSG_GPIO_MENU_PREV || event == U8X8_MSG_GPIO_MENU_DOWN )
143 | {
144 | if ( cursor == 0 )
145 | cursor = button_cnt;
146 | cursor--;
147 | u8x8_draw_button_line(u8x8, y, u8x8_GetCols(u8x8), cursor, buttons);
148 | }
149 | }
150 | return 0;
151 | }
152 |
153 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8x8_selection_list.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8x8_selection_list.c
4 |
5 | selection list with scroll option
6 |
7 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
8 |
9 | Copyright (c) 2016, 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 "u8x8.h"
39 |
40 | /*
41 | increase the cursor position
42 | */
43 | void u8sl_Next(u8sl_t *u8sl)
44 | {
45 | u8sl->current_pos++;
46 | if ( u8sl->current_pos >= u8sl->total )
47 | {
48 | u8sl->current_pos = 0;
49 | u8sl->first_pos = 0;
50 | }
51 | else
52 | {
53 | if ( u8sl->first_pos + u8sl->visible <= u8sl->current_pos + 1 )
54 | {
55 | u8sl->first_pos = u8sl->current_pos - u8sl->visible + 1;
56 | }
57 | }
58 | }
59 |
60 | void u8sl_Prev(u8sl_t *u8sl)
61 | {
62 | if ( u8sl->current_pos == 0 )
63 | {
64 | u8sl->current_pos = u8sl->total - 1;
65 | u8sl->first_pos = 0;
66 | if ( u8sl->total > u8sl->visible )
67 | u8sl->first_pos = u8sl->total - u8sl->visible;
68 | }
69 | else
70 | {
71 | u8sl->current_pos--;
72 | if ( u8sl->first_pos > u8sl->current_pos )
73 | u8sl->first_pos = u8sl->current_pos;
74 | }
75 | }
76 |
77 | void u8x8_DrawSelectionList(u8x8_t *u8x8, u8sl_t *u8sl, u8x8_sl_cb sl_cb, const void *aux)
78 | {
79 | uint8_t i;
80 | for( i = 0; i < u8sl->visible; i++ )
81 | {
82 | sl_cb(u8x8, u8sl, i+u8sl->first_pos, aux);
83 | }
84 | }
85 |
86 | /* selection list with string line */
87 | void u8x8_sl_string_line_cb(u8x8_t *u8x8, u8sl_t *u8sl, uint8_t idx, const void *aux)
88 | {
89 | const char *s;
90 | uint8_t row;
91 | /* calculate offset from display upper border */
92 | row = u8sl->y;
93 |
94 | /* calculate target pos */
95 | row += idx;
96 | row -= u8sl->first_pos;
97 |
98 | /* check whether this is the current cursor line */
99 | if ( idx == u8sl->current_pos )
100 | u8x8_SetInverseFont(u8x8, 1);
101 | else
102 | u8x8_SetInverseFont(u8x8, 0);
103 |
104 | /* get the line from the array */
105 | s = u8x8_GetStringLineStart(idx, (const char *)aux);
106 |
107 | /* draw the line */
108 | if ( s == NULL )
109 | s = "";
110 | u8x8_DrawUTF8Line(u8x8, u8sl->x, row, u8x8_GetCols(u8x8), s);
111 | u8x8_SetInverseFont(u8x8, 0);
112 | }
113 |
114 | /*
115 | title: NULL for no title, valid str for title line. Can contain mutliple lines, separated by '\n'
116 | start_pos: default position for the cursor (starts with 1)
117 | sl: string list (list of strings separated by \n)
118 | returns 0 if user has pressed the home key
119 | returns the selected line+1 if user has pressed the select key (e.g. 1 for the first line)
120 | */
121 | uint8_t u8x8_UserInterfaceSelectionList(u8x8_t *u8x8, const char *title, uint8_t start_pos, const char *sl)
122 | {
123 | u8sl_t u8sl;
124 | uint8_t event;
125 | uint8_t title_lines;
126 |
127 | if ( start_pos > 0 )
128 | start_pos--;
129 |
130 | u8sl.visible = u8x8_GetRows(u8x8);
131 | u8sl.total = u8x8_GetStringLineCnt(sl);
132 | u8sl.first_pos = 0;
133 | u8sl.current_pos = start_pos;
134 | u8sl.x = 0;
135 | u8sl.y = 0;
136 |
137 |
138 | //u8x8_ClearDisplay(u8x8); /* not required because all is 100% filled */
139 | u8x8_SetInverseFont(u8x8, 0);
140 |
141 | if ( title != NULL )
142 | {
143 | title_lines = u8x8_DrawUTF8Lines(u8x8, u8sl.x, u8sl.y, u8x8_GetCols(u8x8), title);
144 | u8sl.y+=title_lines;
145 | u8sl.visible-=title_lines;
146 | }
147 |
148 | if ( u8sl.current_pos >= u8sl.total )
149 | u8sl.current_pos = u8sl.total-1;
150 |
151 |
152 | u8x8_DrawSelectionList(u8x8, &u8sl, u8x8_sl_string_line_cb, sl);
153 |
154 | for(;;)
155 | {
156 | event = u8x8_GetMenuEvent(u8x8);
157 | if ( event == U8X8_MSG_GPIO_MENU_SELECT )
158 | return u8sl.current_pos+1;
159 | else if ( event == U8X8_MSG_GPIO_MENU_HOME )
160 | return 0;
161 | else if ( event == U8X8_MSG_GPIO_MENU_NEXT || event == U8X8_MSG_GPIO_MENU_DOWN )
162 | {
163 | u8sl_Next(&u8sl);
164 | u8x8_DrawSelectionList(u8x8, &u8sl, u8x8_sl_string_line_cb, sl);
165 | }
166 | else if ( event == U8X8_MSG_GPIO_MENU_PREV || event == U8X8_MSG_GPIO_MENU_UP )
167 | {
168 | u8sl_Prev(&u8sl);
169 | u8x8_DrawSelectionList(u8x8, &u8sl, u8x8_sl_string_line_cb, sl);
170 | }
171 | }
172 | }
173 |
174 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8x8_setup.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8x8_setup.c
4 |
5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6 |
7 | Copyright (c) 2016, 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 "u8x8.h"
38 |
39 | /* universal dummy callback, which will be default for all callbacks */
40 | uint8_t u8x8_dummy_cb(U8X8_UNUSED u8x8_t *u8x8, U8X8_UNUSED uint8_t msg, U8X8_UNUSED uint8_t arg_int, U8X8_UNUSED void *arg_ptr)
41 | {
42 | /* the dummy callback will not handle any message and will fail for all messages */
43 | return 0;
44 | }
45 |
46 |
47 | static const u8x8_display_info_t u8x8_null_display_info =
48 | {
49 | /* chip_enable_level = */ 0,
50 | /* chip_disable_level = */ 1,
51 |
52 | /* post_chip_enable_wait_ns = */ 0,
53 | /* pre_chip_disable_wait_ns = */ 0,
54 | /* reset_pulse_width_ms = */ 0,
55 | /* post_reset_wait_ms = */ 0,
56 | /* sda_setup_time_ns = */ 0,
57 | /* sck_pulse_width_ns = */ 0, /* half of cycle time (100ns according to datasheet), AVR: below 70: 8 MHz, >= 70 --> 4MHz clock */
58 | /* sck_clock_hz = */ 4000000UL, /* since Arduino 1.6.0, the SPI bus speed in Hz. Should be 1000000000/sck_pulse_width_ns */
59 | /* spi_mode = */ 0, /* active high, rising edge */
60 | /* i2c_bus_clock_100kHz = */ 4,
61 | /* data_setup_time_ns = */ 0,
62 | /* write_pulse_width_ns = */ 0,
63 | /* tile_width = */ 1, /* 8x8 */
64 | /* tile_hight = */ 1,
65 | /* default_x_offset = */ 0,
66 | /* flipmode_x_offset = */ 0,
67 | /* pixel_width = */ 8,
68 | /* pixel_height = */ 8
69 | };
70 |
71 |
72 | /* a special null device */
73 | uint8_t u8x8_d_null_cb(u8x8_t *u8x8, uint8_t msg, U8X8_UNUSED uint8_t arg_int, U8X8_UNUSED void *arg_ptr)
74 | {
75 | switch(msg)
76 | {
77 | case U8X8_MSG_DISPLAY_SETUP_MEMORY:
78 | u8x8_d_helper_display_setup_memory(u8x8, &u8x8_null_display_info);
79 | break;
80 | case U8X8_MSG_DISPLAY_INIT:
81 | u8x8_d_helper_display_init(u8x8);
82 | break;
83 | }
84 | /* the null device callback will succeed for all messages */
85 | return 1;
86 | }
87 |
88 |
89 | /*
90 | Description:
91 | Setup u8x8
92 | Args:
93 | u8x8 An empty u8x8 structure
94 | */
95 | void u8x8_SetupDefaults(u8x8_t *u8x8)
96 | {
97 | u8x8->display_info = NULL;
98 | u8x8->display_cb = u8x8_dummy_cb;
99 | u8x8->cad_cb = u8x8_dummy_cb;
100 | u8x8->byte_cb = u8x8_dummy_cb;
101 | u8x8->gpio_and_delay_cb = u8x8_dummy_cb;
102 | u8x8->is_font_inverse_mode = 0;
103 | u8x8->device_address = 0;
104 | u8x8->utf8_state = 0; /* also reset by u8x8_utf8_init */
105 | u8x8->i2c_address = 255;
106 | u8x8->debounce_default_pin_state = 255; /* assume all low active buttons */
107 |
108 | #ifdef U8X8_USE_PINS
109 | {
110 | uint8_t i;
111 | for( i = 0; i < U8X8_PIN_CNT; i++ )
112 | u8x8->pins[i] = U8X8_PIN_NONE;
113 | }
114 | #endif
115 | }
116 |
117 |
118 | /*
119 | Description:
120 | Setup u8x8 and assign the callback function. The dummy
121 | callback "u8x8_dummy_cb" can be used, if no callback is required.
122 | This setup will not communicate with the display itself.
123 | Use u8x8_InitDisplay() to send the startup code to the Display.
124 | Args:
125 | u8x8 An empty u8x8 structure
126 | display_cb Display/controller specific callback function
127 | cad_cb Display controller specific communication callback function
128 | byte_cb Display controller/communication specific callback funtion
129 | gpio_and_delay_cb Environment specific callback function
130 |
131 | */
132 | void u8x8_Setup(u8x8_t *u8x8, u8x8_msg_cb display_cb, u8x8_msg_cb cad_cb, u8x8_msg_cb byte_cb, u8x8_msg_cb gpio_and_delay_cb)
133 | {
134 | /* setup defaults and reset pins to U8X8_PIN_NONE */
135 | u8x8_SetupDefaults(u8x8);
136 |
137 | /* setup specific callbacks */
138 | u8x8->display_cb = display_cb;
139 | u8x8->cad_cb = cad_cb;
140 | u8x8->byte_cb = byte_cb;
141 | u8x8->gpio_and_delay_cb = gpio_and_delay_cb;
142 |
143 | /* setup display info */
144 | u8x8_SetupMemory(u8x8);
145 | }
146 |
147 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8x8_string.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8x8_string.c
4 |
5 | string line procedures
6 |
7 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
8 |
9 | Copyright (c) 2016, 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 "u8x8.h"
39 |
40 | uint8_t u8x8_GetStringLineCnt(const char *str)
41 | {
42 | char e;
43 | uint8_t line_cnt = 1;
44 | if ( str == NULL )
45 | return 0;
46 | for(;;)
47 | {
48 | e = *str;
49 | if ( e == '\0' )
50 | break;
51 | str++;
52 | if ( e == '\n' )
53 | line_cnt++;
54 | }
55 | return line_cnt;
56 | }
57 |
58 |
59 | /*
60 | Assumes strings, separated by '\n' in "str".
61 | Returns the string at index "line_idx". First strng has line_idx = 0
62 | Example:
63 | Returns "xyz" for line_idx = 1 with str = "abc\nxyz"
64 | Support both UTF8 and normal strings.
65 | */
66 | const char *u8x8_GetStringLineStart(uint8_t line_idx, const char *str )
67 | {
68 | char e;
69 | uint8_t line_cnt = 1;
70 |
71 | if ( line_idx == 0 )
72 | return str;
73 |
74 | for(;;)
75 | {
76 | e = *str;
77 | if ( e == '\0' )
78 | break;
79 | str++;
80 | if ( e == '\n' )
81 | {
82 | if ( line_cnt == line_idx )
83 | return str;
84 | line_cnt++;
85 | }
86 | }
87 | return NULL; /* line not found */
88 | }
89 |
90 | /* copy until first '\n' or '\0' in str */
91 | /* Important: There is no string overflow check, ensure */
92 | /* that the destination buffer is large enough */
93 | void u8x8_CopyStringLine(char *dest, uint8_t line_idx, const char *str)
94 | {
95 | if ( dest == NULL )
96 | return;
97 | str = u8x8_GetStringLineStart( line_idx, str );
98 | if ( str != NULL )
99 | {
100 | for(;;)
101 | {
102 | if ( *str == '\n' || *str == '\0' )
103 | break;
104 | *dest = *str;
105 | dest++;
106 | str++;
107 | }
108 | }
109 | *dest = '\0';
110 | }
111 |
112 | /*
113 | Draw a string
114 | Extend the string to size "w"
115 | Center the string within "w"
116 | return the size of the string
117 |
118 | */
119 | uint8_t u8x8_DrawUTF8Line(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t w, const char *s)
120 | {
121 | uint8_t d, lw;
122 | uint8_t cx, dx;
123 |
124 | d = 0;
125 |
126 | lw = u8x8_GetUTF8Len(u8x8, s);
127 | if ( lw < w )
128 | {
129 | d = w;
130 | d -=lw;
131 | d /= 2;
132 | }
133 |
134 | cx = x;
135 | dx = cx + d;
136 | while( cx < dx )
137 | {
138 | u8x8_DrawUTF8(u8x8, cx, y, " ");
139 | cx++;
140 | }
141 | cx += u8x8_DrawUTF8(u8x8, cx, y, s);
142 | dx = x + w;
143 | while( cx < dx )
144 | {
145 | u8x8_DrawUTF8(u8x8, cx, y, " ");
146 | cx++;
147 | }
148 | cx -= x;
149 | return cx;
150 | }
151 |
152 | /*
153 | draw several lines at position x,y.
154 | lines are stored in s and must be separated with '\n'.
155 | lines can be centered with respect to "w"
156 | if s == NULL nothing is drawn and 0 is returned
157 | returns the number of lines in s
158 | */
159 | uint8_t u8x8_DrawUTF8Lines(u8x8_t *u8x8, uint8_t x, uint8_t y, uint8_t w, const char *s)
160 | {
161 | uint8_t i;
162 | uint8_t cnt;
163 | cnt = u8x8_GetStringLineCnt(s);
164 | for( i = 0; i < cnt; i++ )
165 | {
166 | u8x8_DrawUTF8Line(u8x8, x, y, w, u8x8_GetStringLineStart(i, s));
167 | y++;
168 | }
169 | return cnt;
170 | }
171 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8x8_u16toa.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8x8_u16toa.c
4 |
5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6 |
7 | Copyright (c) 2016, 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 "u8x8.h"
39 |
40 | const char *u8x8_u16toap(char * dest, uint16_t v)
41 | {
42 | uint8_t pos;
43 | uint8_t d;
44 | uint16_t c;
45 | c = 10000;
46 | for( pos = 0; pos < 5; pos++ )
47 | {
48 | d = '0';
49 | while( v >= c )
50 | {
51 | v -= c;
52 | d++;
53 | }
54 | dest[pos] = d;
55 | c /= 10;
56 | }
57 | dest[5] = '\0';
58 | return dest;
59 | }
60 |
61 | /* v = value, d = number of digits */
62 | const char *u8x8_u16toa(uint16_t v, uint8_t d)
63 | {
64 | static char buf[6];
65 | d = 5-d;
66 | return u8x8_u16toap(buf, v) + d;
67 | }
68 |
69 |
--------------------------------------------------------------------------------
/libraries/U8g2/src/clib/u8x8_u8toa.c:
--------------------------------------------------------------------------------
1 | /*
2 |
3 | u8x8_u8toa.c
4 |
5 | Universal 8bit Graphics Library (https://github.com/olikraus/u8g2/)
6 |
7 | Copyright (c) 2016, 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 "u8x8.h"
38 |
39 | static const unsigned char u8x8_u8toa_tab[3] = { 100, 10, 1 } ;
40 | const char *u8x8_u8toap(char * dest, uint8_t v)
41 | {
42 | uint8_t pos;
43 | uint8_t d;
44 | uint8_t c;
45 | for( pos = 0; pos < 3; pos++ )
46 | {
47 | d = '0';
48 | c = *(u8x8_u8toa_tab+pos);
49 | while( v >= c )
50 | {
51 | v -= c;
52 | d++;
53 | }
54 | dest[pos] = d;
55 | }
56 | dest[3] = '\0';
57 | return dest;
58 | }
59 |
60 | /* v = value, d = number of digits */
61 | const char *u8x8_u8toa(uint8_t v, uint8_t d)
62 | {
63 | static char buf[4];
64 | d = 3-d;
65 | return u8x8_u8toap(buf, v) + d;
66 | }
67 |
68 |
--------------------------------------------------------------------------------