Init
This commit is contained in:
+99
@@ -0,0 +1,99 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "driver/gpio.h"
|
||||
#include "drivers/fonts.h"
|
||||
#include "drivers/i2c.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
#include "drivers/battery.h"
|
||||
#include "drivers/pins.h"
|
||||
|
||||
#include "drivers/bmi270.h"
|
||||
#include "drivers/es8311.h"
|
||||
#include "drivers/sdcard.h"
|
||||
#include "drivers/irled.h"
|
||||
#include "drivers/i2s.h"
|
||||
#include "drivers/st7789.h"
|
||||
#include "drivers/tca8418.h"
|
||||
#include "drivers/ws2812.h"
|
||||
#include "hal/gpio_types.h"
|
||||
#include "projdefs.h"
|
||||
|
||||
void app_main(void) {
|
||||
set_pin_dirs();
|
||||
printf("boot\n");
|
||||
battery_start_task();
|
||||
|
||||
gpio_set_level(LCD_BACKLIGHT_AND_RGB_POWER, 1);
|
||||
|
||||
gpio_set_level(IR_LED, 0);
|
||||
|
||||
i2c_init(BUS_I2C_SDA, BUS_I2C_SCL);
|
||||
|
||||
|
||||
ws2812_init();
|
||||
st7789_init();
|
||||
bmi270_init();
|
||||
es8311_init();
|
||||
tca8418_init();
|
||||
initSD();
|
||||
ir_pwm_init();
|
||||
ir_carrier_off();
|
||||
|
||||
st7789_fill(0xFFFF);
|
||||
st7789_fill_rect(1, 1, LCD_WIDTH - 2, LCD_HEIGHT - 2, 0x0000);
|
||||
|
||||
st7789_flush_full();
|
||||
|
||||
st7789_flush();
|
||||
|
||||
ws2812_send_rgb(255, 255, 255);
|
||||
|
||||
/*
|
||||
static int16_t micbuf[512];
|
||||
|
||||
audio_read(micbuf, 512);
|
||||
|
||||
audio_write(micbuf, 512);
|
||||
|
||||
|
||||
*/
|
||||
audio_beep();
|
||||
|
||||
while (1) {
|
||||
|
||||
// keyboard
|
||||
uint8_t key;
|
||||
uint8_t pressed;
|
||||
|
||||
char buf[64];
|
||||
st7789_fill_rect(1, 1, LCD_WIDTH - 2, LCD_HEIGHT - 2, 0x0000);
|
||||
st7789_draw_string(10, 10, "CARDPUTER TEST", 0xFFFF, 0x0000, false, font5x7);
|
||||
while (tca8418_read(&key, &pressed)) {
|
||||
|
||||
snprintf(buf, sizeof(buf), "key=%c %s %d %s", getKeyboardChar(key),
|
||||
getKeyboardKeyName(key), key, pressed ? "pressed" : "released");
|
||||
printf("%s\n", buf);
|
||||
|
||||
st7789_draw_string(30, 30, buf, 0x07E0, 0x0000, true, fontHitachi);
|
||||
}
|
||||
bmi270_data_t bmiData;
|
||||
|
||||
bmi270_read(&bmiData);
|
||||
|
||||
snprintf(buf, sizeof(buf), "acc %d %d %d gyro %d %d %d\n",
|
||||
bmiData.ax, bmiData.ay, bmiData.az,
|
||||
bmiData.gx, bmiData.gy, bmiData.gz);
|
||||
|
||||
st7789_draw_string(30, 60, buf, 0x07E0, 0x0000, true, fontHitachi);
|
||||
|
||||
|
||||
snprintf(buf, sizeof(buf), "Battery: %d%%(%.3fV)", getBatteryPercentage(), getBatteryVoltage());
|
||||
st7789_draw_string(100, 10, buf, 0x07E0, 0x0000, true, fontHitachi);
|
||||
st7789_flush();
|
||||
|
||||
vTaskDelay(pdMS_TO_TICKS(20)); //50 fps max
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user