Testing OLED
This commit is contained in:
parent
3de900cf9b
commit
6971275630
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -4,6 +4,7 @@
|
||||
"05_border_frame.h": "c",
|
||||
"04_diagonal.h": "c",
|
||||
"epaper.h": "c",
|
||||
"font.h": "c"
|
||||
"font.h": "c",
|
||||
"oled.h": "c"
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ target_sources(app PRIVATE
|
||||
src/main.c
|
||||
src/lora/encryption.c
|
||||
src/lora/synch.c
|
||||
src/epaper/epaper.c
|
||||
src/oled/oled.c
|
||||
src/utils/constAndVars.c
|
||||
src/utils/buttons.c
|
||||
src/utils/leds.c
|
||||
|
10
README.rst
10
README.rst
@ -12,13 +12,13 @@ BUSY (lila) CN9:7 GPIO B10
|
||||
|
||||
OLED
|
||||
Ports: Anschluss Port
|
||||
VCC VSS (grau) CN6:4 5V
|
||||
GND VDD (braun) CN6:6 GND
|
||||
VCC VDD (braun) CN6:4 5V
|
||||
GND VSS (grau) CN6:6 GND
|
||||
DIN D0 (blau) CN5:4 GPIO A7
|
||||
CLK D1 (gelb) CN5:6 GPIO A5
|
||||
CS CS (orange) CN9:7 GPIO B10
|
||||
DC A0 (grün) CN9:6 GPIO B8
|
||||
RST RST (weiß) CN9:8 GPIO C1
|
||||
CS CS (orange) CN9:7 GPIO B10 !! A8
|
||||
DC A0 (grün) CN9:6 GPIO B8 !! A9
|
||||
RST RST (weiß) CN9:8 GPIO C1 !! A10
|
||||
|
||||
|
||||
Bei start:
|
||||
|
@ -1,4 +1,44 @@
|
||||
&spi1{
|
||||
/*
|
||||
* Copyright (c) 2024 Marvin Herold
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Finale, funktionierende Konfiguration: Wir weichen dem LED-Konflikt
|
||||
* auf Port B aus, indem wir den sauberen SPI1-Port auf Port A verwenden.
|
||||
*/
|
||||
|
||||
/ {
|
||||
aliases {
|
||||
oled = &oled;
|
||||
display = &oled;
|
||||
};
|
||||
};
|
||||
|
||||
// Wir aktivieren SPI1, das auf konfliktfreien Pins liegt.
|
||||
// Keine LED-Deaktivierung mehr nötig!
|
||||
&spi1 {
|
||||
// Wir referenzieren die Standard-Pins für SPI1
|
||||
// MISO (PA6) und NSS (PA4) brauchen wir nicht, also lassen wir sie weg.
|
||||
pinctrl-0 = <&spi1_sck_pa5 &spi1_mosi_pa7>;
|
||||
pinctrl-names = "default";
|
||||
status = "okay";
|
||||
|
||||
// Unser Display hängt jetzt an SPI1
|
||||
oled: oled@0 {
|
||||
compatible = "marvin,oled128x64";
|
||||
reg = <0>;
|
||||
spi-max-frequency = <2000000>;
|
||||
|
||||
// Die anderen GPIOs bleiben unverändert, sie sind nicht im Konflikt.
|
||||
dc-gpios = <&gpiob 8 GPIO_ACTIVE_HIGH>;
|
||||
reset-gpios = <&gpioc 1 GPIO_ACTIVE_LOW>;
|
||||
cs-gpios = <&gpiob 10 GPIO_ACTIVE_LOW>;
|
||||
label = "OLED";
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/*&spi1{
|
||||
status = "okay";
|
||||
pinctrl-0 = < &spi1_nss_pa4 &spi1_sck_pa5 &spi1_miso_pa6 &spi1_mosi_pa7 >;
|
||||
pinctrl-names = "default";
|
||||
@ -16,4 +56,4 @@
|
||||
busy-gpios = <&gpiob 10 GPIO_ACTIVE_HIGH>;
|
||||
cs-gpios = <&gpioa 4 GPIO_ACTIVE_HIGH>;
|
||||
};
|
||||
};
|
||||
};*/
|
@ -2,8 +2,8 @@
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/sys/printk.h>
|
||||
|
||||
#include "epaper/epaper.h"
|
||||
//#include "oled/oled.h"
|
||||
//#include "epaper/epaper.h"
|
||||
#include "oled/oled.h"
|
||||
|
||||
#include "utils/buttons.h"
|
||||
#include "utils/leds.h"
|
||||
@ -45,5 +45,5 @@ int main(void)
|
||||
}*/
|
||||
|
||||
char toDraw = '4';
|
||||
draw_something(toDraw);
|
||||
oled_draw_something(toDraw);
|
||||
}
|
||||
|
@ -23,18 +23,10 @@ static struct spi_config spi_cfg = {
|
||||
};
|
||||
|
||||
// --- Raw GPIO Control ---
|
||||
// Wir ignorieren jetzt die ACTIVE_LOW/HIGH Flags und steuern die Spannung direkt.
|
||||
// Das ist der ultimative Test.
|
||||
|
||||
// Für CS (soll bei Aktivierung LOW sein)
|
||||
#define OLED_CS_ENABLE gpio_pin_set_raw(oled_cs.port, oled_cs.pin, 0)
|
||||
#define OLED_CS_DISABLE gpio_pin_set_raw(oled_cs.port, oled_cs.pin, 1)
|
||||
|
||||
// Für DC (soll bei Daten HIGH sein)
|
||||
#define OLED_DC_COMMAND gpio_pin_set_raw(oled_dc.port, oled_dc.pin, 0)
|
||||
#define OLED_DC_DATA gpio_pin_set_raw(oled_dc.port, oled_dc.pin, 1)
|
||||
|
||||
// Für RST (soll bei Reset LOW sein)
|
||||
#define OLED_RST_ASSERT gpio_pin_set_raw(oled_reset.port, oled_reset.pin, 0)
|
||||
#define OLED_RST_DEASSERT gpio_pin_set_raw(oled_reset.port, oled_reset.pin, 1)
|
||||
|
||||
@ -71,31 +63,61 @@ void OLED_Reset(void) {
|
||||
oled_driver_delay_xms(100);
|
||||
}
|
||||
|
||||
/*
|
||||
* ========================================================================
|
||||
* NEUE, ROBUSTERE INITIALISIERUNGSSEQUENZ (abgeleitet von U8g2 für SSD1309)
|
||||
* ========================================================================
|
||||
*/
|
||||
void OLED_HW_Init(void) {
|
||||
OLED_Reset();
|
||||
printk("Sende Initialisierungssequenz (Raw-Modus)...\n");
|
||||
OLED_Write_Command(0xAE); // Display OFF
|
||||
OLED_Write_Command(0xD5); OLED_Write_Command(0x80); // Set Clock
|
||||
OLED_Write_Command(0xA8); OLED_Write_Command(0x3F); // Set MUX
|
||||
OLED_Write_Command(0xD3); OLED_Write_Command(0x00); // Set Display Offset
|
||||
OLED_Write_Command(0x40); // Set Start Line
|
||||
OLED_Write_Command(0x8D); OLED_Write_Command(0x14); // Charge Pump
|
||||
OLED_Write_Command(0x20); OLED_Write_Command(0x00); // Memory Mode
|
||||
OLED_Write_Command(0xA1); // Seg Remap
|
||||
OLED_Write_Command(0xC8); // COM Scan Dec
|
||||
OLED_Write_Command(0xDA); OLED_Write_Command(0x12); // COM Pins
|
||||
OLED_Write_Command(0x81); OLED_Write_Command(0xCF); // Contrast
|
||||
OLED_Write_Command(0xD9); OLED_Write_Command(0xF1); // Pre-charge
|
||||
OLED_Write_Command(0xDB); OLED_Write_Command(0x40); // VCOMH
|
||||
OLED_Write_Command(0xA4); // Display ON from RAM
|
||||
OLED_Write_Command(0xA6); // Normal Display
|
||||
OLED_Write_Command(0xAF); // Display ON in normal mode
|
||||
printk("Initialisierung gesendet (Raw-Modus).\n");
|
||||
printk("Sende ROBUSTERE Initialisierungssequenz...\n");
|
||||
|
||||
OLED_Write_Command(0xAE); // Display OFF
|
||||
|
||||
OLED_Write_Command(0xD5); // Set Display Clock Divide Ratio
|
||||
OLED_Write_Command(0xA0); // Ein anderer, oft stabilerer Wert
|
||||
|
||||
OLED_Write_Command(0xA8); // Set Multiplex Ratio
|
||||
OLED_Write_Command(0x3F); // 64 MUX
|
||||
|
||||
OLED_Write_Command(0xD3); // Set Display Offset
|
||||
OLED_Write_Command(0x00); // No offset
|
||||
|
||||
OLED_Write_Command(0x40); // Set Start Line (0)
|
||||
|
||||
OLED_Write_Command(0x20); // Set Memory Addressing Mode
|
||||
OLED_Write_Command(0x00); // Horizontal Addressing Mode
|
||||
|
||||
OLED_Write_Command(0xA1); // Set Segment Re-map (column address 127 is mapped to SEG0)
|
||||
OLED_Write_Command(0xC8); // Set COM Output Scan Direction (scanned from COM[N-1] to COM0)
|
||||
|
||||
OLED_Write_Command(0xDA); // Set COM Pins Hardware Configuration
|
||||
OLED_Write_Command(0x12);
|
||||
|
||||
OLED_Write_Command(0x81); // Set Contrast Control
|
||||
OLED_Write_Command(0x80); // Ein mittlerer Wert
|
||||
|
||||
OLED_Write_Command(0xD9); // Set Pre-charge Period
|
||||
OLED_Write_Command(0x22); // Ein anderer, oft stabilerer Wert
|
||||
|
||||
OLED_Write_Command(0xDB); // Set VCOMH Deselect Level
|
||||
OLED_Write_Command(0x34); // ~0.83 x VCC
|
||||
|
||||
OLED_Write_Command(0xA4); // Entire Display ON, Output follows RAM content
|
||||
OLED_Write_Command(0xA6); // Set Normal Display
|
||||
|
||||
OLED_Write_Command(0x8D); // Charge Pump Setting
|
||||
OLED_Write_Command(0x14); // Enable Charge Pump
|
||||
|
||||
OLED_Write_Command(0xAF); // Display ON
|
||||
|
||||
printk("Initialisierung gesendet.\n");
|
||||
}
|
||||
|
||||
|
||||
void OLED_WhiteScreen_White(void) {
|
||||
uint8_t buffer[128];
|
||||
memset(buffer, 0xFF, sizeof(buffer)); // Alles auf 1 setzen für Weiß
|
||||
memset(buffer, 0x00, sizeof(buffer)); // Alles auf 1 setzen für Weiß
|
||||
for (uint8_t page = 0; page < 8; page++) {
|
||||
OLED_Write_Command(0xB0 + page); // Set Page Address
|
||||
OLED_Write_Command(0x00); // Lower column start address
|
||||
|
Loading…
x
Reference in New Issue
Block a user