Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void buttonHandle(void) {
- if (get_button(BUTTON) == GPIO_PIN_RESET) {
- if (chargedLEDS == 6) { // pārbauda vai visi led deg
- if (latDir != ',') {
- if (zona_anounced == 0) || (zona_anounced != zona) {
- switch(zona) {
- case 6:
- // Play "Kā ziemeļpolā"
- break;
- case 5:
- // Play "Auksts"
- break;
- case 4:
- // Play "Silts"
- break;
- case 3:
- // Play "Pavisam silts"
- break;
- case 2:
- // Play "Karsts"
- break;
- case 1:
- // Play "Deg"
- break;
- default:
- // Not posible
- }
- lastdist = curdist;
- chargedLEDS = 0;
- }
- } else {
- // Play "Nav signāla"
- }
- latDir = ',';
- }
- while (get_button(BUTTON) == GPIO_PIN_RESET) {}
- HAL_Delay(70);
- return;
- }
- }
- int main(void) {
- HAL_Init();
- SystemInit();
- SystemClock_Config();
- cstm_f1_uart2_init(9600);
- initPC13();
- button_init();
- while(1) {
- if (cstm_uart2_data_available()) {
- cstm_uart2_receive_data(myBuff, GPS_CHUNK_SIZE, 10);
- decodeGPS(myBuff);
- if (latDir != ',') { // Looks like we have lock and valid GPS data!
- curdist = distance(lat, lon);
- if (curdist > 100) zona = 6
- else if (curdist <= 100) zona = 5
- else if (curdist <= 50) zona = 4
- else if (curdist <= 25) zona = 3
- else if (curdist <= 15) zona = 2
- else if (curdist <= 5) zona = 1;
- HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_13);
- }
- }
- buttonHandle();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement