/** * Show command */ void command_show(char* line) { char cmd[MAX_BUFFER]; char key[MAX_BUFFER]; char func[MAX_BUFFER]; char arg1[MAX_BUFFER]; char arg2[MAX_BUFFER]; int argc = sscanf(line, "%s %s %s %s %s", cmd, key, func, arg1, arg2); if (argc < 2) { goto invalid; } MATRIX_GUARD(key); if (argc == 2) { display(m); return; } const uint32_t v1 = atoll(arg1) - 1; if (v1 >= g_order) { goto invalid; } if (argc == 4 && strcasecmp(func, "row") == 0) { display_row(m, v1); } else if (argc == 4 && strcasecmp(func, "column") == 0) { display_column(m, v1); } else if (argc == 5 && strcasecmp(func, "element") == 0) { const uint32_t v2 = atoll(arg2) - 1; if (v2 >= g_order) { goto invalid; } display_element(m, v1, v2); } return; invalid: puts("invalid arguments"); }
/* ===================================================================*/ void wheel_StartColumn() { bool finished = FALSE; uint16_t periodOffset; static windowT window; static bool topFromBeginning; surfaceT leftside; switch (wait_mode) { case TO_FIRST: currColumn = 0; if (front) { // front wheel -> upper window is first window = UPPER; // left (standard, TOP on left) // -> display from back (TOP) topFromBeginning = FALSE; // bottom is vice versa } else { // rear wheel -> lower window is first window = LOWER; // left (standard, TOP on left) // -> display from the beginning topFromBeginning = TRUE; // bottom is vice versa } display_column(topFromBeginning, window, currColumn); periodOffset = rotTimerCh0 + columnPeriodTicks; RotTimer_SetOffsetTicks(RotTimerPtr, COLUMN_TIMER_CHANNEL, periodOffset); wait_mode = IN_FIRST; break; case IN_FIRST: if (++currColumn >= MAX_COLUMN) { // window finished // set time (delay between) for the second window if (front) { periodOffset = rotTimerCh0 + (rotationTime * (between_front / 360.0)) / TIMER_TICK; } else { periodOffset = rotTimerCh0 + (rotationTime * (between_rear / 360.0)) / TIMER_TICK; } RotTimer_SetOffsetTicks(RotTimerPtr, COLUMN_TIMER_CHANNEL, periodOffset); clear_leds(TOPSIDE); write_ledColumn(TOPSIDE); wait_ledColumn(); clear_leds(BOTTOMSIDE); write_ledColumn(BOTTOMSIDE); wait_ledColumn(); wait_mode = TO_SECOND; if (displayMode[TOPSIDE][UPPER] == LIGHT) { wait_mode = NOT_WAITING; } enable_bling[TOPSIDE] = TRUE; enable_bling[BOTTOMSIDE] = TRUE; } else { display_column(topFromBeginning, window, currColumn); // timeout for the next column periodOffset = rotTimerCh0 + columnPeriodTicks; RotTimer_SetOffsetTicks(RotTimerPtr, COLUMN_TIMER_CHANNEL, periodOffset); } break; case TO_SECOND: currColumn = 0; if (front) { // front wheel -> bottom window is second window = LOWER; // left (standard, TOP on left) // -> display from the beginning topFromBeginning = TRUE; // bottom is vice versa } else { // rear wheel -> top window is second window = UPPER; // left (standard, TOP on left) // -> display from back (TOP) topFromBeginning = FALSE; // bottom is vice versa } display_column(topFromBeginning, window, currColumn); // timeout for the next column periodOffset = rotTimerCh0 + columnPeriodTicks; RotTimer_SetOffsetTicks(RotTimerPtr, COLUMN_TIMER_CHANNEL, periodOffset); wait_mode = IN_SECOND; break; case IN_SECOND: if (++currColumn >= MAX_COLUMN) { // window finished RotTimer_SetOffsetTicks(RotTimerPtr, COLUMN_TIMER_CHANNEL, 0xffff); clear_leds(TOPSIDE); write_ledColumn(TOPSIDE); wait_ledColumn(); clear_leds(BOTTOMSIDE); write_ledColumn(BOTTOMSIDE); wait_ledColumn(); wait_mode = NOT_WAITING; enable_bling[TOPSIDE] = TRUE; enable_bling[BOTTOMSIDE] = TRUE; } else { display_column(topFromBeginning, window, currColumn); // timeout for the next column periodOffset = rotTimerCh0 + columnPeriodTicks; RotTimer_SetOffsetTicks(RotTimerPtr, COLUMN_TIMER_CHANNEL, periodOffset); } break; case NOT_WAITING: break; } }