add u8g2 and ui libs (#91)

* add u8g2 and ui libs

* add display driver and usage example

* not init display in test mode

* change todo text

* fix removed code

* Target f2 (#107)

* add ioc for flipperzero f2

* add generated f1 files to f2

* regenerate cubemx

* invert initial state of led

* blink backligh

* shutdown backlight on idle
This commit is contained in:
coreglitch
2020-09-09 22:12:09 +06:00
committed by GitHub
parent 884fccc591
commit 5c81bb8abc
1119 changed files with 1394482 additions and 7 deletions

View File

@@ -42,6 +42,13 @@ inline bool app_gpio_read(GpioPin gpio) {
return false;
}
typedef enum {
GPIO_PIN_SET = 1,
GPIO_PIN_RESET = 0
} HAL_GPIO_PIN_STATE;
void HAL_GPIO_WritePin(const char* port, uint32_t pin, HAL_GPIO_PIN_STATE state);
void delay_us(uint32_t time);
void pwm_set(float value, float freq, TIM_HandleTypeDef* tim, uint32_t channel);
@@ -82,3 +89,21 @@ inline void app_tim_stop() {
#define GPIO_PIN_13 13
#define GPIO_PIN_14 14
#define GPIO_PIN_15 15
#define DISPLAY_RST_GPIO_Port "DISPLAY RST"
#define DISPLAY_DI_Pin 0
#define DISPLAY_DI_GPIO_Port "DISPLAY DI"
#define DISPLAY_RST_Pin 0
#define DISPLAY_CS_GPIO_Port "DISPLAY CS"
#define DISPLAY_CS_Pin 0
#define DISPLAY_BACKLIGHT_GPIO_Port "BACKLIGHT"
#define DISPLAY_BACKLIGHT_Pin 0
typedef const char* SPI_HandleTypeDef;
typedef uint32_t HAL_StatusTypeDef;
HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef *hspi, uint8_t *pData, uint16_t Size, uint32_t Timeout);

View File

@@ -42,6 +42,26 @@ C_SOURCES += ../core/tty_uart.c
C_SOURCES += ../core/furi.c
C_SOURCES += ../core/furi_ac.c
C_SOURCES += ../lib/u8g2/u8x8_d_st7565.c \
../lib/u8g2/u8g2_d_setup.c \
../lib/u8g2/u8g2_intersection.c \
../lib/u8g2/u8g2_setup.c \
../lib/u8g2/u8g2_d_memory.c \
../lib/u8g2/u8x8_cad.c \
../lib/u8g2/u8x8_byte.c \
../lib/u8g2/u8x8_gpio.c \
../lib/u8g2/u8x8_display.c \
../lib/u8g2/u8x8_setup.c \
../lib/u8g2/u8g2_hvline.c \
../lib/u8g2/u8g2_ll_hvline.c \
../lib/u8g2/u8g2_circle.c \
../lib/u8g2/u8g2_box.c \
../lib/u8g2/u8g2_buffer.c \
../lib/u8g2/u8g2_font.c \
../lib/u8g2/u8g2_fonts.c \
../lib/u8g2/u8x8_8x8.c \
../lib/u8g2/u8g2_bitmap.c
# System applications
ifeq ($(TEST), 1)
@@ -51,8 +71,17 @@ C_SOURCES += ../applications/tests/test_index.c
C_DEFS += -DTEST
endif
ifneq ($(TEST), 1)
C_SOURCES += ../applications/display-u8g2/display-u8g2.c
endif
# Examples
# TODO example without condition
ifneq ($(TEST), 1)
C_SOURCES += ../applications/examples/u8g2_example.c
endif
ifeq ($(EXAMPLE_BLINK), 1)
C_SOURCES += ../applications/examples/blink.c
C_DEFS += -DEXAMPLE_BLINK
@@ -112,6 +141,7 @@ RUST_LIB_CMD = cd $(RUST_LIB_SRC) && cargo build -p flipper-core $(RUST_LIB_FLAG
C_INCLUDES = \
-IInc \
-I../applications \
-I../lib \
-I../core \
-I../core-rs/flipper-core/bindings
@@ -140,24 +170,25 @@ LDFLAGS = $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-
# default action: build all
all: $(BUILD_DIR)/$(TARGET)
run: all
$(BUILD_DIR)/$(TARGET)
rust_lib:
$(RUST_LIB_CMD)
example_blink:
rm -f $(BUILD_DIR)/app.o
EXAMPLE_BLINK=1 make
$(BUILD_DIR)/$(TARGET)
EXAMPLE_BLINK=1 make run
example_uart_write:
rm -f $(BUILD_DIR)/app.o
EXAMPLE_UART_WRITE=1 make
$(BUILD_DIR)/$(TARGET)
EXAMPLE_UART_WRITE=1 make run
example_ipc:
rm -f $(BUILD_DIR)/app.o
EXAMPLE_IPC=1 make
$(BUILD_DIR)/$(TARGET)
EXAMPLE_IPC=1 make run
test:
rm -f $(BUILD_DIR)/app.o

View File

@@ -38,4 +38,20 @@ void delay_us(uint32_t time) {
void pwm_set(float value, float freq, TIM_HandleTypeDef* tim, uint32_t channel) {
printf("[TIM] set pwm %d:%d %f Hz, %f%%\n", *tim, channel, freq, value * 100.);
}
}
void HAL_GPIO_WritePin(const char* port, uint32_t pin, HAL_GPIO_PIN_STATE state) {
printf("[GPIO] set pin %s:%d = %d\n", port, pin, state);
}
HAL_StatusTypeDef HAL_SPI_Transmit(SPI_HandleTypeDef* hspi, uint8_t *pData, uint16_t size, uint32_t Timeout) {
printf("[SPI] write %d to %s: ", size, *hspi);
for(size_t i = 0; i < size; i++) {
printf("%02X ", pData[i]);
}
printf("\n");
return 0;
}
SPI_HandleTypeDef hspi1 = "spi1";