Quellcode durchsuchen

detect if OLED is plugged in

Thomas Buck vor 8 Monaten
Ursprung
Commit
bbd5b07fd0
6 geänderte Dateien mit 20 neuen und 6 gelöschten Zeilen
  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 Datei anzeigen

@@ -6,4 +6,4 @@
6 6
 	url = https://github.com/raspberrypi/pico-sdk
7 7
 [submodule "firmware/pico-ssd1306"]
8 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 Datei anzeigen

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

+ 1
- 1
firmware/include/lcd.h Datei anzeigen

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

+ 1
- 1
firmware/pico-ssd1306

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

+ 13
- 2
firmware/src/lcd.c Datei anzeigen

@@ -32,6 +32,7 @@ static i2c_inst_t *gpio_inst_i2c = i2c1;
32 32
 static const uint gpio_num_i2c[2] = { 14, 15 };
33 33
 
34 34
 static ssd1306_t lcd = {0};
35
+static bool found = false;
35 36
 
36 37
 void lcd_init(void) {
37 38
     i2c_init(gpio_inst_i2c, 2UL * 1000UL * 1000UL);
@@ -41,10 +42,20 @@ void lcd_init(void) {
41 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 59
     ssd1306_clear(&lcd);
49 60
 
50 61
     ssd1306_draw_string(&lcd, 0, 0, 2,

+ 1
- 1
firmware/src/main.c Datei anzeigen

@@ -48,7 +48,7 @@ int main(void) {
48 48
 
49 49
     buttons_init();
50 50
     lcd_init();
51
-    lcd_splash();
51
+    lcd_splash_version();
52 52
 
53 53
     debug("go");
54 54
 

Laden…
Abbrechen
Speichern