Esempio n. 1
0
void main(){

    int16_t yaw, pitch, roll;
    bool valid;

    // Initialize all subsystems.
    oledInit();
    oledWriteBuffer();
    imuInit();

    // Enable interrupts.
    RCONbits.IPEN = 1;      // Enable priority levels
    INTCONbits.GIEL = 1;    // Enable low-priority interrupts to CPU.
    INTCONbits.GIEH = 1;    // Enable all interrupts.

    // Spin-up IMU and delay on splash screen.
    imuSpinup();
    delayxs(2);

    // Main loop.
    while (true){

        /* // Update AHRS solution. */
        valid = ahrsUpdate(&yaw, &pitch, &roll);

        // Write the EFIS to the frame buffer.
        efisDraw(yaw, pitch, roll, valid);

        // Write the frame buffer.
        oledWriteBuffer();
    }
}
Esempio n. 2
0
int main(void)
{
	__stack_chk_guard = random32();
	setup();
	memory_protect();
	oledInit();

	// at least one button is unpressed
	uint16_t state = gpio_port_read(BTN_PORT);
	if ((state & BTN_PIN_YES) == BTN_PIN_YES || (state & BTN_PIN_NO) == BTN_PIN_NO) {

		check_firmware_sanity();

		oledClear();
		oledDrawBitmap(40, 0, &bmp_logo64_empty);
		oledRefresh();

		uint8_t hash[32];
		if (!signatures_ok(hash)) {
			show_unofficial_warning(hash);
		}

		load_app();

	}

	bootloader_loop();

	return 0;
}
Esempio n. 3
0
File: main.c Progetto: szczys/SloJak
int main(void)
{
    init_IO();
    init_interrupts();
    oledInit();
    _delay_ms(200);

    oledSetCursor(cursX, cursY);
    putChar(66,1);
    advanceCursor(6);

    compose();

    initMenu();

    while(1)
    {
        static uint16_t butCounter = 0;
        if (butCounter++ > 65000) {
            //FIXME: Proper button debounce and handling
            butCounter = 0;
            uint8_t readButtons = BUT_PIN;
            if (~readButtons & BUT_LEFT) {
                ++goLeft;
            }
            if (~readButtons & BUT_SEL) {
                ++goSel;
            }
        }

        if (knobChange) {
            if (knobChange > 0) {
                //menuUp();
                knobLeft();
            }
            else {
                //menuDn();
                knobRight();
            }
            knobChange = 0;
        }

        if (goSel) {
            //Lookup and execute action
            doSelect[optionIndex]();
            goSel = 0;
        }
        else if (goLeft) {
            doBack();
            goLeft = 0;
        }
    }
}
Esempio n. 4
0
int main(void)
{
#ifndef APPVER
	setup();
#endif
	__stack_chk_guard = random32(); // this supports compiler provided unpredictable stack protection checks
#ifndef APPVER
	memory_protect();
	oledInit();
#endif

#ifndef APPVER
	// at least one button is unpressed
	uint16_t state = gpio_port_read(BTN_PORT);
	int unpressed = ((state & BTN_PIN_YES) == BTN_PIN_YES || (state & BTN_PIN_NO) == BTN_PIN_NO);

	if (firmware_present() && unpressed) {

		oledClear();
		oledDrawBitmap(40, 0, &bmp_logo64_empty);
		oledRefresh();

		uint8_t hash[32];
		int signed_firmware = signatures_ok(hash);
		if (SIG_OK != signed_firmware) {
			show_unofficial_warning(hash);
			timer_init();
		}

		load_app(signed_firmware);
	}
#endif

	bootloader_loop();

	return 0;
}