Example #1
0
void bluefruit_keyboard_print_report(report_keyboard_t *report)
{
    if (!debug_keyboard) return;
    dprintf("keys: "); for (int i = 0; i < KEYBOARD_REPORT_KEYS; i++) { debug_hex8(report->keys[i]); dprintf(" "); }
    dprintf(" mods: "); debug_hex8(report->mods);
    dprintf(" reserved: "); debug_hex8(report->reserved); 
    dprintf("\n");
}
Example #2
0
static void bluefruit_serial_send(uint8_t data)
{
#ifdef BLUEFRUIT_TRACE_SERIAL
    dprintf(" ");
    debug_hex8(data);
    dprintf(" ");
#endif
    serial_send(data);
}
Example #3
0
int main (void) {
	debug_init();

	config_read();

	motor_init();
	lightsensor_init();

	find_start_position();

	debug_fstr("done");
	lcd_setcursor(2,2);
	debug_fstr("durr ");
	debug_hex8(conf_address);

	/* now listen on the bus and wait for data */
	si2cs_init();
	sei();

	/* we're done with setup. activate watchdog */
	wdt_enable(WDTO_4S);

	while (1) {
		/* moving to a new position */

		motor_current_active();

		uint16_t steps_since_start = 0;

		while (current_pos != target_pos) {
			/* do one step */
			motor_step();

			/* update current position.
			 * overflow of the current position is handled by the
			 * light sensor interrupt
			 */
			current_pos++;

			/* acceleration */
			if (steps_since_start > 20 && steps_until_done > 20) {
				_delay_ms(3);
			} else if (steps_since_start > 10 && steps_until_done > 10) {
				_delay_ms(6);
			} else if (steps_since_start > 5 && steps_until_done > 5) {
				_delay_ms(9);
			} else {
				_delay_ms(10);
			}
			steps_since_start++;
			steps_until_done--;

			wdt_reset();
		}

		/* holding the current position */

		motor_current_idle();

		while (current_pos == target_pos) {
			_delay_ms(20);

			wdt_reset();
		}
	}
}