mirror of
https://github.com/CovidBraceletPrj/CovidBracelet.git
synced 2025-06-24 23:48:06 +02:00
Add powersave and string drawing APIs
This commit is contained in:
parent
d6270ffb3f
commit
e52b37d0d5
@ -1,12 +1,17 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
#ifdef PLATFORM_PINETIME
|
#ifdef PLATFORM_PINETIME
|
||||||
#include "display_pinetime.h"
|
#include "display_pinetime.h"
|
||||||
#define platform_display_init pinetime_display_init
|
#define platform_display_init pinetime_display_init
|
||||||
#define platform_display_set_brightness pinetime_display_set_brightness
|
#define platform_display_set_brightness pinetime_display_set_brightness
|
||||||
|
#define platform_display_draw_string pinetime_display_draw_string
|
||||||
|
#define platform_display_set_powersave pinetime_display_set_powersave
|
||||||
#else
|
#else
|
||||||
static inline int platform_display_init() { return 0; }
|
static inline int platform_display_init() { return 0; }
|
||||||
static inline void platform_display_set_brightness(uint8_t brightness) { }
|
static inline void platform_display_set_brightness(uint8_t brightness) { (void)brightness; }
|
||||||
|
static inline void platform_display_draw_string(uint8_t x, uint8_t y, const char *str) { (void)x; (void)y; (void)str; }
|
||||||
|
static inline void platform_display_set_powersave(bool powersave) { (void)powersave; }
|
||||||
#endif
|
#endif
|
@ -94,17 +94,13 @@ void pinetime_display_set_brightness(const uint8_t brightness) {
|
|||||||
|
|
||||||
int pinetime_display_init() {
|
int pinetime_display_init() {
|
||||||
int err;
|
int err;
|
||||||
uint8_t ppt;
|
|
||||||
|
|
||||||
// Get display device
|
// Get display device
|
||||||
pinetime_display.display_dev = device_get_binding("ST7789V");
|
pinetime_display.display_dev = device_get_binding("ST7789V");
|
||||||
if (!pinetime_display.display_dev) {
|
if (!pinetime_display.display_dev) {
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Patch in gpio based backlight control
|
|
||||||
// ((struct display_driver_api *)pinetime_display.display_dev->api)->set_brightness = set_brightness;
|
|
||||||
|
|
||||||
pinetime_display.backlight_dev = device_get_binding(BACKLIGHT_DEVNAME);
|
pinetime_display.backlight_dev = device_get_binding(BACKLIGHT_DEVNAME);
|
||||||
if (!pinetime_display.backlight_dev) {
|
if (!pinetime_display.backlight_dev) {
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
@ -127,49 +123,26 @@ int pinetime_display_init() {
|
|||||||
}
|
}
|
||||||
pinetime_display_set_brightness(0);
|
pinetime_display_set_brightness(0);
|
||||||
|
|
||||||
/*
|
|
||||||
gpio_pin_set(backlight_dev, PIN, 1);
|
|
||||||
|
|
||||||
display_blanking_off(pinetime_display.display_dev);
|
|
||||||
|
|
||||||
|
|
||||||
err = cfb_framebuffer_init(pinetime_display.display_dev);
|
|
||||||
if (err) {
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = cfb_framebuffer_clear(pinetime_display.display_dev, false);
|
|
||||||
if (err) {
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
ppt = cfb_get_display_parameter(pinetime_display.display_dev, CFB_DISPLAY_PPT);
|
|
||||||
|
|
||||||
err = cfb_print(pinetime_display.display_dev, "Hello World", 0, 0);
|
|
||||||
if (err) {
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = cfb_framebuffer_finalize(pinetime_display.display_dev);
|
|
||||||
if (err) {
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
display_write(pinetime_display.display_dev, 0, 0, &buffer_desc, white_8x8);
|
|
||||||
|
|
||||||
display_blanking_off(pinetime_display.display_dev);
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Set up graphics library
|
// Set up graphics library
|
||||||
// Populate all hardware callbacks with dummy functions, we do already have a driver
|
// Populate all hardware callbacks with dummy functions, we do already have a driver
|
||||||
u8x8_Setup(&u8x8, u8x8_cmd_cb, u8x8_dummy_cb, u8x8_dummy_cb, u8x8_dummy_cb);
|
u8x8_Setup(&u8x8, u8x8_cmd_cb, u8x8_dummy_cb, u8x8_dummy_cb, u8x8_dummy_cb);
|
||||||
u8x8_InitDisplay(&u8x8);
|
u8x8_InitDisplay(&u8x8);
|
||||||
u8x8_ClearDisplay(&u8x8);
|
u8x8_ClearDisplay(&u8x8);
|
||||||
u8x8_SetPowerSave(&u8x8, false);
|
u8x8_SetPowerSave(&u8x8, true);
|
||||||
u8x8_SetFont(&u8x8, u8x8_font_amstrad_cpc_extended_f);
|
u8x8_SetFont(&u8x8, u8x8_font_amstrad_cpc_extended_f);
|
||||||
u8x8_DrawString(&u8x8, 0, 0, "Hello World");
|
|
||||||
display_blanking_off(pinetime_display.display_dev);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pinetime_display_draw_string(uint8_t x, uint8_t y, const char *str) {
|
||||||
|
u8x8_DrawString(&u8x8, x, y, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
void pinetime_display_set_powersave(bool powersave) {
|
||||||
|
u8x8_SetPowerSave(&u8x8, false);
|
||||||
|
if (powersave) {
|
||||||
|
pinetime_display_set_brightness(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -1,6 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
int pinetime_display_init();
|
int pinetime_display_init();
|
||||||
void pinetime_display_set_brightness(uint8_t brightness);
|
void pinetime_display_set_brightness(uint8_t brightness);
|
||||||
|
void pinetime_display_draw_string(uint8_t x, uint8_t y, const char *str);
|
||||||
|
void pinetime_display_set_powersave(bool powersave);
|
||||||
|
@ -30,7 +30,9 @@ void main(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
platform_display_set_powersave(false);
|
||||||
platform_display_set_brightness(0xff);
|
platform_display_set_brightness(0xff);
|
||||||
|
platform_display_draw_string(0, 0, "Hello World!");
|
||||||
|
|
||||||
// first init everything
|
// first init everything
|
||||||
// Use custom randomization as the mbdet_tls context initialization messes with the Zeyhr BLE stack.
|
// Use custom randomization as the mbdet_tls context initialization messes with the Zeyhr BLE stack.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user