//
// Therm Firmware
// Copyright 2017 Ethan Zonca
// Author(s): Ethan Zonca
//
#include "stm32f3xx_hal.h"
#include "config.h"
#include "watchdog.h"
#include "system.h"
#include "gpio.h"
#include "error.h"
#include "flash.h"
#include "ssd1306.h"
#include "dma.h"
#include "interrupts.h"
#include "buttons.h"
int main(void)
{
sysclock_init();
hal_init();
gpio_init();
ssd1306_init();
ssd1306_clearscreen();
ssd1306_drawlogo();
HAL_Delay(2000);
flash_init();
watchdog_init();
//just some example code for getting flash values
// flash_getsettings()->values.can_id = 67;
//
// if(flash_getsettings()->values.can_id == 12);
// ssd1306_drawstring(const char *dataPtr, unsigned char row, unsigned char xPos)
// ssd1306_drawstring("[ ProtoFuse ]", 0, 0);
float temp_counter = 0;
// Software timers
uint32_t last_screen_update_time = HAL_GetTick();
while (1)
{
// function that checks all the buttons
freaking_debounce();
// Grab and transmit data
if(HAL_GetTick() - last_screen_update_time > 100)
{
HAL_GPIO_TogglePin(LED_GPIO_Port, LED_PIN);
char buffer[256];
snprintf(buffer, 256, "Counter: %.1f", temp_counter);
ssd1306_drawstring(buffer, 3, 45);
ssd1306_drawstring("Therm 0.4", 0, 40);
temp_counter = temp_counter + 0.1;
last_screen_update_time = HAL_GetTick();
}
watchdog_feed();
}
}