void reconstruct_reverse_track() { if (get_step_count() > 0) { TRACE_DEBUG("-- reconstruct_reverse_track -- \r\n"); char txt_buff[16]; sprintf(txt_buff, "Total steps: %2d", get_step_count()); HY1602F6_Log("Reversing track", txt_buff); init_oa_configuration(); CD4053_EnableIRSensors(); waitms(1000); int step_count = get_step_count() - 1; for (; step_count >= 0; step_count--) { char lcd_buff1[16]; sprintf(lcd_buff1, "angle: %3d", (int) steps_data[step_count]); char lcd_buff2[16]; sprintf(lcd_buff2, "step: %3d", step_count); HY1602F6_Log(lcd_buff1, lcd_buff2); turn_of_angle(steps_data[step_count]); go_prosto(); } Kierunek(RIGHT_ENGINES, STOP_GEAR); Kierunek(LEFT_ENGINES, STOP_GEAR); } else { TRACE_WARNING("-- No steps recorded. --\r\n"); HY1602F6_Log("Invalid track", "No data found"); } }
/**@brief Button event handler. * * @param[in] pin_no The pin number of the button pressed. */ static void button_event_handler(uint8_t pin_no) { switch (pin_no) { case EVAL_BOARD_BUTTON_0: mlog_str("button 0 pressed\r\n"); if (connected) ble_oto_send_step_count(&m_oto, get_step_count()); motor_off(); led_stop(); break; case EVAL_BOARD_BUTTON_1: mlog_str("button 1 pressed\r\n"); if (!connected) advertising_start(); break; default: APP_ERROR_HANDLER(pin_no); } }
void onStepDetectedCallback(void) { TRACE_DEBUG("-- Step detected %3d -- \r\n", get_step_count()); // mag_info mg_i = MMC212xM_GetMagneticFieldInfo(&twid); steps_data[get_step_count() - 1] = get_descrete_angle( L3G4200D_GetData().sAngle_z); L3G4200D_Reset(&twid); char txt_buff[16]; sprintf(txt_buff, "s: %2d a: %3d", get_step_count(), (int) steps_data[get_step_count() - 1]); HY1602F6_Log("Step detected", txt_buff); TRACE_INFO("-- Detected angle: %4d, Descrete angle: %d -- \r\n", L3G4200D_GetData().sAngle_z, (int)steps_data[get_step_count() - 1]); }
static void select_click_handler(ClickRecognizerRef recognizer, void *context) { bool running = app_worker_is_running(); if (running){ get_step_count(); static char step_count[] = "9999"; snprintf(step_count, sizeof("9999"), "%d", s_worker_steps); text_layer_set_text(text_layer, step_count); }else{ text_layer_set_text(text_layer, "Not Running"); } }
void menu_window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_frame(window_layer); step_count = get_step_count(); info_bar = layer_create(GRect(0, 0, bounds.size.w, 44)); layer_add_child(window_layer, info_bar); layer_set_update_proc(info_bar, update_info_bar); main_menu = menu_layer_create(GRect(0, 44, bounds.size.w, bounds.size.h-44)); menu_layer_set_highlight_colors(main_menu, GColorTiffanyBlue, GColorWhite); menu_layer_set_click_config_onto_window(main_menu, window); menu_layer_set_callbacks(main_menu, NULL, (MenuLayerCallbacks) { .get_num_rows = (MenuLayerGetNumberOfRowsInSectionsCallback)menu_get_num_rows_callback, .get_cell_height = (MenuLayerGetCellHeightCallback)get_cell_height_callback, .draw_row = (MenuLayerDrawRowCallback)menu_draw_row_callback, .select_click = (MenuLayerSelectCallback)menu_select_callback, .get_num_sections = (MenuLayerGetNumberOfSectionsCallback)menu_get_num_sections_callback, });