Add examples and tasks

This commit is contained in:
Thammi 2015-03-11 21:36:52 +01:00
parent abeced81a2
commit 0339089da2
4 changed files with 100 additions and 0 deletions

19
firmware/apps/example_1.c Normal file
View File

@ -0,0 +1,19 @@
#include <avr/io.h>
#include <pentabug/app.h>
// was bedeuten die einzelnen Worte?
// was passiert?
// geht das einfacher?
static void example(void) {
if(!(PINB & 1)) {
PORTD &= ~(1 << 4);
}
if(!(PINB & 2)) {
PORTC &= ~(1 << 2);
}
}
REG(example);

18
firmware/apps/example_2.c Normal file
View File

@ -0,0 +1,18 @@
#include <pentabug/hal.h>
#include <pentabug/app.h>
// was erwartest du das passiert?
// wie kann man das Problem lösen?
static void example(void) {
if(button_state(LEFT)) {
led_inv(LEFT);
}
if(button_state(RIGHT)) {
motor_inv();
}
}
REG(example);

24
firmware/apps/example_3.c Normal file
View File

@ -0,0 +1,24 @@
#include <pentabug/hal.h>
#include <pentabug/app.h>
#include <pentabug/music.h>
static void example(void) {
if(button_clicked(LEFT)) {
set_note(NOTE_C, 4);
wait_ms(500);
set_note(NOTE_D, 4);
wait_ms(500);
stop_note();
}
if(button_clicked(RIGHT)) {
set_note(NOTE_D, 4);
wait_ms(500);
set_note(NOTE_C, 4);
wait_ms(500);
stop_note();
}
}
REG(example);

39
firmware/apps/example_4.c Normal file
View File

@ -0,0 +1,39 @@
#include <pentabug/hal.h>
#include <pentabug/app.h>
// was passiert?
// gibt es probleme?
// wie kann man das problem lösen?
static void init(void) {
led_on(RIGHT);
led_on(LEFT);
}
static void example(void) {
led_inv(LEFT);
led_inv(RIGHT);
wait_ms(500);
led_inv(LEFT);
wait_ms(500);
led_inv(RIGHT);
wait_ms(500);
if(button_clicked(LEFT)) {
motor_inv();
wait_ms(500);
motor_inv();
wait_ms(500);
motor_inv();
wait_ms(500);
motor_inv();
wait_ms(500);
}
}
REGISTER(example, init, NULL);