Compare commits

...

3 commits

Author SHA1 Message Date
de1af41d42 luftchen: experiment with the display
All checks were successful
continuous-integration/drone/push Build is passing
2024-06-16 15:47:27 +02:00
24927ff8e7 luftchen: add the OLED to the board configuration 2024-06-16 15:47:09 +02:00
07a0bb56fa luftchen: ignore the cland cache directory 2024-06-16 15:46:52 +02:00
4 changed files with 51 additions and 35 deletions

1
.gitignore vendored
View file

@ -1,3 +1,4 @@
.vscode/
build/
drone/
.cache/

View file

@ -5,11 +5,13 @@
*/
#include <stdio.h>
#include <zephyr/kernel.h>
#include <zephyr/drivers/display.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/kernel.h>
/* 1000 msec = 1 sec */
#define SLEEP_TIME_MS 1000
#define SLEEP_TIME_MS 1000
/* The devicetree node identifier for the "led0" alias. */
#define LED0_NODE DT_ALIAS(led0)
@ -18,13 +20,27 @@
* A build error on this line means your board is unsupported.
* See the sample documentation for information on how to fix this.
*/
static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios);
// static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(LED0_NODE, gpios);
int main(void)
{
int ret;
bool led_state = true;
const struct device *display =
DEVICE_DT_GET(DT_CHOSEN(zephyr_display));
display_capabilities capabilities;
display_get_capabilities(display, &capabilities);
uint32_t buf = 0;
display_buffer_descriptor buf_desc = {
.buf_size = 4, .width = 8, .height = 1, .pitch = 8};
display_write(display, 0, 0, &buf_desc, &buf);
int x = 0;
#if 0
if (!gpio_is_ready_dt(&led)) {
return 0;
}
@ -33,16 +49,25 @@ int main(void)
if (ret < 0) {
return 0;
}
#endif
while (1) {
#if 0
ret = gpio_pin_toggle_dt(&led);
if (ret < 0) {
return 0;
}
#endif
for (int x = 0; x < 128; ++x) {
for (int y = 0; y < 64; y += 8) {
display_write(display, x, y, &buf_desc, &buf);
}
}
buf = ~buf;
led_state = !led_state;
printf("LED state: %s\n", led_state ? "ON" : "OFF");
k_msleep(SLEEP_TIME_MS);
printf("XLED state: %s\n", led_state ? "ON" : "OFF");
// display_write(display, x, x, &buf_desc, &buf);
// k_msleep(SLEEP_TIME_MS);
}
return 0;
}

View file

@ -11,19 +11,7 @@
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,console = &debug0;
zephyr,shell-uart = &usart1;
};
leds {
compatible = "gpio-leds";
red_led: led0 {
gpios = <&gpioa 2 GPIO_ACTIVE_HIGH>;
};
};
aliases {
led0 = &red_led;
zephyr,display = &hs96l03;
};
};
@ -31,23 +19,21 @@
status = "okay";
};
&gpioa {
&i2c1 {
status = "okay";
};
clock-frequency = <400000>;
&pinctrl {
usart1_default: usart1_default {
group0 {
pinmux = <USART1_TX_PD5_0>, <USART1_RX_PD6_0>;
bias-pull-up;
drive-push-pull;
};
hs96l03: hs96l03@3c {
compatible = "hs99l03", "solomon,ssd1306fb";
reg = <0x3c>;
width = <128>;
height = <64>;
segment-offset = <0>;
page-offset = <0>;
display-offset = <0>;
multiplex-ratio = <63>;
segment-remap;
com-invdir;
prechargep = <0x22>;
};
};
&usart1 {
status = "okay";
current-speed = <115200>;
pinctrl-0 = <&usart1_default>;
pinctrl-names = "default";
};

View file

@ -3,5 +3,9 @@ CONFIG_SOC_WCH_CH32V00X_PLL=y
CONFIG_SOC_WCH_CH32V00X_HSI_AS_PLLSRC=y
CONFIG_SOC_WCH_CH32V00X_PLL_AS_SYSCLK=y
CONFIG_I2C=y
CONFIG_CLOCK_CONTROL=y
CONFIG_PINCTRL=y
CONFIG_DISPLAY=y
CONFIG_SSD1306=y