int main() { red_error err; char buffer[] = {0x01, 0x02, 0x03, 0x04, 0x05}; redOpen(); printf("redOpen done\n"); int a = redSymbol("a"); int o_b_2 = redSymbol("o_b_2"); int print = redSymbol("print"); int o_b = redSymbol("o_b"); int b = redSymbol("b"); red_value obj; redSet(o_b, redLoadPath("o/b")); redDo("?? o_b"); redSet(o_b_2, redPath(redWord("o"), redWord("b"), redInteger(2), 0)); redSet(a, (red_value) redBlock(redInteger(42), redString("hello"), 0)); redDo("?? a foreach v a [probe v]"); redPrint(redGet(a)); red_value value = redDo("$%$"); if (redTypeOf(value) == RED_TYPE_ERROR) redProbe(value); redProbe(redCall(redWord("what-dir"), 0)); redCall(redWord("print"), redDo("system/version"), 0); redCall(redGet(print), redFloat(99.0), 0); redRoutine(redWord("c-add"), "[a [integer!] b [integer!]]", (void*) &add); //if (redTypeOf(value) == RED_TYPE_ERROR) redProbe(value); if (err = redHasError()) redPrint(err); else redDo("probe c-add 2 3 probe :c-add"); redDo("o: object [b: {hello}]"); redDo("?? o_b"); redProbe(redGet(o_b)); redProbe(redGet(o_b_2)); redProbe(redGetPath(redGet(o_b_2))); redSetPath(redGet(o_b), redInteger(123)); redProbe(redGetPath(redGet(o_b))); obj = redGet(redSymbol("o")); redProbe(redGetField(obj, b)); redSetField(obj, b, redInteger(99)); redProbe(redGetField(obj, b)); red_binary bin = redBinary(buffer, 5); redProbe(bin); redClose(); return 0; }
void mainMenu() { menuMax = 4; selectedMenu = NOT_SELECTED; currentMenu = 0; bool state = false; while(selectedMenu == NOT_SELECTED) { if (currentMenu == 0) { // Firing Mode (toggle green then red) state = !state; redSet(!state); greenSet(state); delay_ms(100); } else if (currentMenu == 1) { // Firing Rate (fast green blink) state = !state; redOff(); greenSet(state); delay_ms(50); } else if (currentMenu == 2) { // Burst size (three red blinks) lightsOff(); // Display as three blinks of red then pause and repeat for (uint8_t i = 0; i < 3; i++) { redOn(); delay_ms(100); redOff(); if (i == 2) { for (uint8_t i = 0; i < 100; i++) { delay_ms(10); if (selectedMenu != NOT_SELECTED) { break; } } } else { delay_ms(100); } } } else if (currentMenu == 3) { // Ammo Limit (Solid Red) redOn(); greenOff(); } else if (currentMenu == 4) { // Safety Shot (Solid Green) redOff(); greenOn(); } } }
void firingModeMenu() { menuMax = 3; selectedMenu = NOT_SELECTED; currentMenu = FIRING_MODE; bool state = LOW; while(selectedMenu == NOT_SELECTED) { if (currentMenu == 0) { state = !state; redSet(state); greenOff(); delay_ms(50); } else if (currentMenu == 1) { // Three Round Burst lightsOff(); // Display as three blinks of green then pause and repeat for (uint8_t i = 0; i < 3; i++) { greenOn(); delay_ms(100); greenOff(); if (selectedMenu != NOT_SELECTED) { break; } if (i == 2) { delay_ms(1000); } else { delay_ms(100); } } } else if (currentMenu == 2) { // Auto Response lightsOff(); // Display as blink green, blink red, then pause greenOn(); delay_ms(100); greenOff(); delay_ms(100); redOn(); delay_ms(100); redOff(); if (selectedMenu != NOT_SELECTED) { break; } delay_ms(1000); } else if (currentMenu == 3) { // Auto Response redOff(); greenOn(); } } if (selectedMenu >= 0 && selectedMenu <= 3) { eeprom_write_byte(&EEPROM_FIRING_MODE[currentSelector][CURRENT_PRESET[currentSelector]], selectedMenu); successBlink(); } else { failureBlink(); } }