diff --git a/.cproject b/.cproject --- a/.cproject +++ b/.cproject @@ -56,7 +56,9 @@ + + @@ -70,7 +72,9 @@ + + @@ -84,6 +88,8 @@ + + diff --git a/inc/buttons.h b/inc/buttons.h deleted file mode 100644 --- a/inc/buttons.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * buttons.h - * - * Created on: Oct 22, 2016 - * Author: Nicholas Orlando - */ - -#ifndef BUTTONS_H_ -#define BUTTONS_H_ - -enum _btn_state_id -{ - NOT_PRESSED = 0, - PRESSED = 1, - HELD_SHORT = 2, - HELD_LONG = 3, -}; - -void freaking_debounce(void); - -#endif /* BUTTONS_H_ */ diff --git a/inc/config.h b/inc/config.h --- a/inc/config.h +++ b/inc/config.h @@ -30,16 +30,8 @@ #define LED_POWER GPIOF,GPIO_PIN_0 #define MAX_CS GPIOA,GPIO_PIN_15 -#define SW_BTN GPIOB, GPIO_PIN_4 -#define SW_UP GPIOB, GPIO_PIN_7 -#define SW_DOWN GPIOB, GPIO_PIN_3 -#define SW_LEFT GPIOB, GPIO_PIN_5 -#define SW_RIGHT GPIOB, GPIO_PIN_6 - #define SSR_PIN GPIOA, GPIO_PIN_1 -// Visual niceness -#define hal_init() HAL_Init() // Add bootloader option to top of idle screen menu #define BOOTLOADER_SHORTCUT diff --git a/inc/dma.h b/inc/dma.h deleted file mode 100644 --- a/inc/dma.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * dma.h - * - * Created on: Aug 9, 2016 - * Author: Nicholas Orlando - */ - -#ifndef DMA_H_ -#define DMA_H_ - -/* Includes ------------------------------------------------------------------*/ -#include "stm32f3xx_hal.h" - -/* DMA memory to memory transfer handles -------------------------------------*/ - -/* USER CODE BEGIN Includes */ - -/* USER CODE END Includes */ - -/* USER CODE BEGIN Private defines */ - -/* USER CODE END Private defines */ - -void MX_DMA_Init(void); - -/* USER CODE BEGIN Prototypes */ - -/* USER CODE END Prototypes */ - -#endif /* DMA_H_ */ diff --git a/inc/error.h b/inc/system/error.h rename from inc/error.h rename to inc/system/error.h diff --git a/inc/flash.h b/inc/system/flash.h rename from inc/flash.h rename to inc/system/flash.h diff --git a/inc/gpio.h b/inc/system/gpio.h rename from inc/gpio.h rename to inc/system/gpio.h diff --git a/inc/interrupts.h b/inc/system/interrupts.h rename from inc/interrupts.h rename to inc/system/interrupts.h diff --git a/inc/system.h b/inc/system/system.h rename from inc/system.h rename to inc/system/system.h diff --git a/inc/watchdog.h b/inc/system/watchdog.h rename from inc/watchdog.h rename to inc/system/watchdog.h diff --git a/src/ssd1306.c b/lib/ssd1306/ssd1306.c rename from src/ssd1306.c rename to lib/ssd1306/ssd1306.c diff --git a/inc/ssd1306.h b/lib/ssd1306/ssd1306.h rename from inc/ssd1306.h rename to lib/ssd1306/ssd1306.h diff --git a/src/buttons.c b/src/buttons.c deleted file mode 100644 --- a/src/buttons.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * buttons.c - * - * Created on: Oct 22, 2016 - * Author: Nicholas Orlando - */ - -#include "stm32f3xx_hal.h" -#include "stm32f3xx.h" -#include "gpio.h" -#include "ssd1306.h" -#include "buttons.h" -#include - - -uint32_t last_button_debounce_time = 0; // the system time at which the button values were last checked -uint32_t debounce_resolution = 5; // period in which to check pin state in milliseconds -float filter_fraction = 0.2; // a number between 0 and 1, which adjusts the heaviness of the filter. - // 0 = never changes and 1 = no filter at all. -uint8_t l_thresh = 20; //lower threshold for when then button is considered pressed vs not pressed. -uint8_t u_thresh = 80; //upper threshold for when then button is considered pressed vs not pressed. - -uint8_t temp_counter = 0; // temporary counter for testing purposes - -float sw_btn_avg = 0; // some sort of running average -uint8_t sw_btn_state = NOT_PRESSED; // the state of the pin after filtering -uint8_t sw_btn_old_state = NOT_PRESSED; // the state of the pin after filtering - -void freaking_debounce(void) -{ - if(HAL_GetTick() - last_button_debounce_time > debounce_resolution) - { - char buffer[256]; // needed for writing stuff to screen - - //averaging to filter button presses - if(HAL_GPIO_ReadPin(SW_BTN) == GPIO_PIN_RESET) - { - sw_btn_avg = sw_btn_avg + filter_fraction * (100 - sw_btn_avg); - } - else - { - sw_btn_avg = sw_btn_avg + filter_fraction * (0 - sw_btn_avg); - } - - // check to see if the btn average value has crossed a threshold - if(sw_btn_avg < l_thresh) - { - sw_btn_state = NOT_PRESSED; -// snprintf(buffer, 256, "NOT_PRESSED"); -// ssd1306_drawstring(buffer, 1, 0); - } - if(sw_btn_avg > u_thresh) - { - sw_btn_state = PRESSED; -// snprintf(buffer, 256, "PRESSED "); -// ssd1306_drawstring(buffer, 1, 0); - } - - // do something when state has changed - if((sw_btn_state == PRESSED) && (sw_btn_old_state == NOT_PRESSED)) - { -// temp_counter++; -// snprintf(buffer, 256, "%i", temp_counter); -// ssd1306_drawstring(buffer, 1, 0); - } - - -// snprintf(buffer, 256, "sw-btn-avg: %.1f", sw_btn_avg); -// ssd1306_drawstring(buffer, 2, 0); - - // save previous button states - sw_btn_old_state = sw_btn_state; - - last_button_debounce_time = HAL_GetTick(); - } -} diff --git a/src/display.c b/src/display.c --- a/src/display.c +++ b/src/display.c @@ -1,6 +1,6 @@ #include "display.h" #include "gpio.h" -#include "ssd1306.h" +#include "ssd1306/ssd1306.h" #include "system/stringhelpers.h" #include "flash.h" diff --git a/src/dma.c b/src/dma.c deleted file mode 100644 --- a/src/dma.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * dma.c - * - * Created on: Aug 9, 2016 - * Author: Nicholas Orlando - */ - -/* Includes ------------------------------------------------------------------*/ -#include "dma.h" - -/* USER CODE BEGIN 0 */ - -/* USER CODE END 0 */ - -/*----------------------------------------------------------------------------*/ -/* Configure DMA */ -/*----------------------------------------------------------------------------*/ - -/* USER CODE BEGIN 1 */ - -/* USER CODE END 1 */ - -/** - * Enable DMA controller clock - */ -void MX_DMA_Init(void) -{ - -} - -/* USER CODE BEGIN 2 */ - -/* USER CODE END 2 */ diff --git a/src/main.c b/src/main.c --- a/src/main.c +++ b/src/main.c @@ -14,10 +14,8 @@ #include "pid.h" #include "error.h" #include "flash.h" -#include "ssd1306.h" -#include "dma.h" +#include "ssd1306/ssd1306.h" #include "interrupts.h" -#include "buttons.h" therm_settings_t set; diff --git a/src/error.c b/src/system/error.c rename from src/error.c rename to src/system/error.c diff --git a/src/flash.c b/src/system/flash.c rename from src/flash.c rename to src/system/flash.c diff --git a/src/gpio.c b/src/system/gpio.c rename from src/gpio.c rename to src/system/gpio.c diff --git a/src/interrupts.c b/src/system/interrupts.c rename from src/interrupts.c rename to src/system/interrupts.c diff --git a/src/sbrk.c b/src/system/sbrk.c rename from src/sbrk.c rename to src/system/sbrk.c diff --git a/src/system.c b/src/system/system.c rename from src/system.c rename to src/system/system.c diff --git a/src/watchdog.c b/src/system/watchdog.c rename from src/watchdog.c rename to src/system/watchdog.c