Add powersave and string drawing APIs
This commit is contained in:
parent
d6270ffb3f
commit
e52b37d0d5
|
@ -1,12 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef PLATFORM_PINETIME
|
||||
#include "display_pinetime.h"
|
||||
#define platform_display_init pinetime_display_init
|
||||
#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
|
||||
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
|
|
@ -94,17 +94,13 @@ void pinetime_display_set_brightness(const uint8_t brightness) {
|
|||
|
||||
int pinetime_display_init() {
|
||||
int err;
|
||||
uint8_t ppt;
|
||||
|
||||
|
||||
// Get display device
|
||||
pinetime_display.display_dev = device_get_binding("ST7789V");
|
||||
if (!pinetime_display.display_dev) {
|
||||
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);
|
||||
if (!pinetime_display.backlight_dev) {
|
||||
return -ENODEV;
|
||||
|
@ -127,49 +123,26 @@ int pinetime_display_init() {
|
|||
}
|
||||
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
|
||||
// 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_InitDisplay(&u8x8);
|
||||
u8x8_ClearDisplay(&u8x8);
|
||||
u8x8_SetPowerSave(&u8x8, false);
|
||||
u8x8_SetPowerSave(&u8x8, true);
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
|
@ -1,6 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
int pinetime_display_init();
|
||||
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;
|
||||
}
|
||||
|
||||
platform_display_set_powersave(false);
|
||||
platform_display_set_brightness(0xff);
|
||||
platform_display_draw_string(0, 0, "Hello World!");
|
||||
|
||||
// first init everything
|
||||
// Use custom randomization as the mbdet_tls context initialization messes with the Zeyhr BLE stack.
|
||||
|
|
Loading…
Reference in New Issue