Demo transmission de commandes Blyss (module blyss) Ce programme permet la transmission de commande Blyss à partie d'ordre donnés sur la liaison série (Réalisation d'une télécommande) :
** Demo Transmission Blyss **
0..8 : Canal
M : Marche
A : Arret
B : Boucle
Canal 4 -> Loop On Off On Off On Off On Off On Off On On
#include <stdio.h>
#include <avrio/delay.h>
#include <avrio/blyss.h>
#include <avrio/tc.h>
#include <avr/pgmspace.h>
#define BAUDRATE 115200
#define PORT "tty0"
#define LOOP_TIME 5000
static const uint8_t my_id[] = {
0x05, 0x08, 0x24
};
int
main (void) {
int c, count;
int channel = -1;
bool state = false;
bool loop = false;
bool txreq = false;
stdout = serial_port;
stderr = serial_port;
stdin = serial_port;
sei();
printf_P (PSTR ("\n\n** Demo Transmission Blyss **\n"
"0..8 : Canal\n"
" M : Marche\n"
" A : Arret\n"
" B : Boucle\n"));
for (;;) {
if ( (c = getchar()) != EOF) {
switch (c) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
channel = c - '0';
printf_P (PSTR ("\nCanal %u -> "), channel);
break;
case 'A':
case 'a':
if (channel != -1) {
state = false;
loop = false;
txreq = true;
}
break;
case 'M':
case 'm':
if (channel != -1) {
state = true;
txreq = true;
loop = false;
}
break;
case 'B':
case 'b':
if (channel != -1) {
loop = true;
count = 0;
printf_P (PSTR ("Loop "));
}
break;
default:
break;
}
}
if (txreq) {
txreq = false;
printf ("%s ", state ? "On" : "Off");
}
if (loop) {
if (count-- == 0) {
count = LOOP_TIME / 100;
state = !state;
txreq = true;
}
}
}
return 0;
}