more work

life update yes I did get an icecream. it wasn't very good tho
This commit is contained in:
Minecon724 2024-05-16 17:41:41 +02:00
parent cc51eb0125
commit 21fe876c0b
Signed by: Minecon724
GPG key ID: 3CCC4D267742C8E8
7 changed files with 73 additions and 2 deletions

View file

@ -19,6 +19,7 @@ cmake_minimum_required(VERSION 3.13)
include(pico_sdk_import.cmake) include(pico_sdk_import.cmake)
project(dp) project(dp)
set(CMAKE_CXX_FLAGS "-O3 -Wall -Wextra")
# initialize the Raspberry Pi Pico SDK # initialize the Raspberry Pi Pico SDK
pico_sdk_init() pico_sdk_init()

1
include/bt4502.h Normal file
View file

@ -0,0 +1 @@
int bt_initialize();

View file

@ -4,4 +4,6 @@
#define SCREEN_WIDTH 240 #define SCREEN_WIDTH 240
#define SCREEN_HEIGHT 360 #define SCREEN_HEIGHT 360
#define BT_NAME "pico bt display"
#endif #endif

View file

@ -1,3 +1,4 @@
void lcd_backlight(bool enabled);
void lcd_start_pixels(); void lcd_start_pixels();
void lcd_end_pixels(); void lcd_end_pixels();
void lcd_put_rgb(uint8_t r, uint8_t g, uint8_t b); void lcd_put_rgb(uint8_t r, uint8_t g, uint8_t b);

57
src/bt4502.c Normal file
View file

@ -0,0 +1,57 @@
#include <string.h>
#include "hardware/gpio.h"
#include "hardware/uart.h"
#include "constants.h"
#define PIN_TX 21 // rxd on module
#define PIN_RX 22 // txd on module
#define PIN_WAKE 18
#define PIN_PDN 19
#define PIN_INT 20
#define UART uart0
static void interrupt_callback() {
// TODO
}
static inline void initialize_pins() {
gpio_init(PIN_WAKE);
gpio_set_dir(PIN_WAKE, GPIO_OUT);
gpio_put(PIN_WAKE, 1);
gpio_init(PIN_PDN);
gpio_set_dir(PIN_PDN, GPIO_OUT);
gpio_put(PIN_PDN, 0);
gpio_init(PIN_INT);
gpio_set_dir(PIN_INT, GPIO_IN);
gpio_set_irq_enabled_with_callback(PIN_INT, GPIO_IRQ_EDGE_FALL, true, &interrupt_callback);
uart_init(UART, 115200);
gpio_set_function(PIN_TX, GPIO_FUNC_UART);
gpio_set_function(PIN_RX, GPIO_FUNC_UART);
}
int bt_initialize() {
initialize_pins();
char ren_cmd[11 + sizeof(BT_NAME)];
strcpy(ren_cmd, "TTM:REN-");
strcat(ren_cmd, BT_NAME);
strcat(ren_cmd, "\r\n\0");
uart_puts(UART, ren_cmd);
char resp[11];
uart_read_blocking(UART, resp, 11);
if (strcmp(resp, "TTM:OK\r\n\0") != 0) {
uart_read_blocking(UART, NULL, 1);
return 1;
}
return 0;
}

View file

@ -1,15 +1,18 @@
#include "hardware/gpio.h" #include "hardware/gpio.h"
#include "pico/stdlib.h"
#include "constants.h" #include "constants.h"
#include "st7789_lcd.h" #include "st7789_lcd.h"
#include "bt4502.h"
int main() { int main() {
gpio_init(PICO_DEFAULT_LED_PIN); gpio_init(PICO_DEFAULT_LED_PIN);
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT); gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
lcd_initialize(); lcd_initialize();
if (bt_initialize() != 0) {
return 1;
}
lcd_start_pixels(); lcd_start_pixels();
for (int y = 0; y < SCREEN_HEIGHT; ++y) { for (int y = 0; y < SCREEN_HEIGHT; ++y) {
@ -23,4 +26,6 @@ int main() {
lcd_end_pixels(); lcd_end_pixels();
gpio_put(PICO_DEFAULT_LED_PIN, 1); gpio_put(PICO_DEFAULT_LED_PIN, 1);
sleep_ms(1000);
lcd_backlight(0);
} }

View file

@ -87,6 +87,10 @@ static inline void initialize_pins() {
gpio_put(PIN_BL, 1); gpio_put(PIN_BL, 1);
} }
void lcd_backlight(bool enabled) {
gpio_put(PIN_BL, enabled);
}
void lcd_start_pixels() { void lcd_start_pixels() {
uint8_t cmd = 0x2c; // RAMWR uint8_t cmd = 0x2c; // RAMWR
lcd_write_cmd(&cmd, 1); lcd_write_cmd(&cmd, 1);