Browse Source

detect if OLED is plugged in

Thomas Buck 8 months ago
parent
commit
bbd5b07fd0
6 changed files with 20 additions and 6 deletions
  1. 1
    1
      .gitmodules
  2. 3
    0
      firmware/CMakeLists.txt
  3. 1
    1
      firmware/include/lcd.h
  4. 1
    1
      firmware/pico-ssd1306
  5. 13
    2
      firmware/src/lcd.c
  6. 1
    1
      firmware/src/main.c

+ 1
- 1
.gitmodules View File

6
 	url = https://github.com/raspberrypi/pico-sdk
6
 	url = https://github.com/raspberrypi/pico-sdk
7
 [submodule "firmware/pico-ssd1306"]
7
 [submodule "firmware/pico-ssd1306"]
8
 	path = firmware/pico-ssd1306
8
 	path = firmware/pico-ssd1306
9
-	url = https://github.com/daschr/pico-ssd1306/
9
+	url = https://github.com/xythobuz/pico-ssd1306

+ 3
- 0
firmware/CMakeLists.txt View File

53
     -Wextra
53
     -Wextra
54
     -Werror
54
     -Werror
55
     -Wshadow
55
     -Wshadow
56
+
57
+    -DSSD1306_DEBUG_PRINT=debug
58
+    -DSSD1306_DEBUG_INCLUDE="log.h"
56
 )
59
 )
57
 
60
 
58
 # suppress some warnings for borked 3rd party files in Pico SDK
61
 # suppress some warnings for borked 3rd party files in Pico SDK

+ 1
- 1
firmware/include/lcd.h View File

26
 #define FONT_WIDTH 5
26
 #define FONT_WIDTH 5
27
 
27
 
28
 void lcd_init(void);
28
 void lcd_init(void);
29
-void lcd_splash(void);
29
+void lcd_splash_version(void);
30
 
30
 
31
 #endif // __LCD_H__
31
 #endif // __LCD_H__

+ 1
- 1
firmware/pico-ssd1306

1
-Subproject commit 8467f5b06ebd7bfa7b53e4ebc83dfdc6f396e4eb
1
+Subproject commit 607fe1cc3c84d662f749e9af0355bc15de0fc48e

+ 13
- 2
firmware/src/lcd.c View File

32
 static const uint gpio_num_i2c[2] = { 14, 15 };
32
 static const uint gpio_num_i2c[2] = { 14, 15 };
33
 
33
 
34
 static ssd1306_t lcd = {0};
34
 static ssd1306_t lcd = {0};
35
+static bool found = false;
35
 
36
 
36
 void lcd_init(void) {
37
 void lcd_init(void) {
37
     i2c_init(gpio_inst_i2c, 2UL * 1000UL * 1000UL);
38
     i2c_init(gpio_inst_i2c, 2UL * 1000UL * 1000UL);
41
         gpio_pull_up(gpio_num_i2c[i]);
42
         gpio_pull_up(gpio_num_i2c[i]);
42
     }
43
     }
43
 
44
 
44
-    ssd1306_init(&lcd, LCD_WIDTH, LCD_HEIGHT, LCD_I2C_ADDR, gpio_inst_i2c);
45
+    found = ssd1306_init(&lcd, LCD_WIDTH, LCD_HEIGHT, LCD_I2C_ADDR, gpio_inst_i2c);
46
+
47
+    if (found) {
48
+        debug("SSD1306 OLED is connected");
49
+    } else {
50
+        debug("No SSD1306 OLED found!");
51
+    }
45
 }
52
 }
46
 
53
 
47
-void lcd_splash(void) {
54
+void lcd_splash_version(void) {
55
+    if (!found) {
56
+        return;
57
+    }
58
+
48
     ssd1306_clear(&lcd);
59
     ssd1306_clear(&lcd);
49
 
60
 
50
     ssd1306_draw_string(&lcd, 0, 0, 2,
61
     ssd1306_draw_string(&lcd, 0, 0, 2,

+ 1
- 1
firmware/src/main.c View File

48
 
48
 
49
     buttons_init();
49
     buttons_init();
50
     lcd_init();
50
     lcd_init();
51
-    lcd_splash();
51
+    lcd_splash_version();
52
 
52
 
53
     debug("go");
53
     debug("go");
54
 
54
 

Loading…
Cancel
Save