Browse Source

premiere mesure de temperature avec le LM35

master
tth 3 years ago
parent
commit
7332f87654
6 changed files with 90 additions and 8 deletions
  1. +2
    -2
      serial/essai.sh
  2. +1
    -1
      serial/t.c
  3. +47
    -0
      simulator/rdtemp/rdtemp.ino
  4. +35
    -0
      viz/curses/7segments.c
  5. +1
    -1
      viz/curses/ecran.c
  6. +4
    -4
      viz/curses/t.c

+ 2
- 2
serial/essai.sh View File

@ -5,9 +5,9 @@ DATAFILE="foo.dat"
TMPFILE="/tmp/dd2data"
IMAGE="graphe.png"
NB_READ=12000
NB_READ=50
./t -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE}
./t -v -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE}
gnuplot << __EOC__
set term png size 1600,512


+ 1
- 1
serial/t.c View File

@ -33,7 +33,7 @@ for (count=0; count<iters; count++) {
fprintf(stderr, "getline #%d -> %d\n", count, foo);
fprintf(stderr, "%s\n", ligne);
}
foo = parse4values(ligne, 'X', datas);
foo = parse4values(ligne, 'T', datas);
//
if (foo >= 0) {
temps = time(NULL);


+ 47
- 0
simulator/rdtemp/rdtemp.ino View File

@ -0,0 +1,47 @@
/*
* lecture des capteurs de temperature LM35
*/
/* -------------------------------------------------- */
#define NBVAL 4
#define DELAI 5000
int values[NBVAL];
/* -------------------------------------------------- */
void setup() {
Serial.begin(9600);
pinMode(LED_BUILTIN, OUTPUT);
delay(2000);
}
/* -------------------------------------------------- */
void updatevalues(void)
{
int foo;
for (foo=0; foo<NBVAL; foo++) {
values[foo] = analogRead(A0);
delay(50);
}
}
/* -------------------------------------------------- */
void sendvalues(void)
{
int foo;
Serial.print("T");
for (foo=0; foo<NBVAL; foo++) {
Serial.print(" ");
Serial.print(values[foo]);
}
Serial.print("\n");
}
/* -------------------------------------------------- */
void loop() {
updatevalues();
sendvalues();
delay(DELAI);
}
/* -------------------------------------------------- */

+ 35
- 0
viz/curses/7segments.c View File

@ -15,6 +15,41 @@
int verbosity;
/* ---------------------------------------------------------------- */
int afficheur_7segs(WINDOW * win, int lig, int col, int bits, int k)
{
int numbit, mask;
for (numbit=0; numbit<8; numbit++) {
mask = 1 << numbit;
switch(mask) {
case 0x01:
case 0x02:
case 0x04:
case 0x08:
case 0x10:
case 0x20:
case 0x40:
case 0x80:
/* decimal point */
break;
default:
fprintf(stderr, "%s mask is wrong\n", __func__);
break;
}
}
return -1;
}
/* ---------------------------------------------------------------- */

+ 1
- 1
viz/curses/ecran.c View File

@ -33,7 +33,7 @@ char buffer[200];
tp = " DD2 MONITORING by tTh 2019 ";
if (NULL != title) tp = title;
barre_inverse('+', 0);
barre_inverse(' ', 0);
standout();
mvaddstr(0, 2, tp);
#if TRACE


+ 4
- 4
viz/curses/t.c View File

@ -22,16 +22,16 @@ water = open_waterfall("premier essai", 0);
for (loop=0; loop<nbl; loop++) {
sprintf(line, "%04X %04X", loop, rand()&0xffff);
sprintf(line, "%06X %04X", loop, rand()&0xffff);
mvwaddstr(stdscr, LINES-1, 1, line);
wrefresh(stdscr);
for (foo=0; foo<4; foo++) {
if (rand()%100<42) {
rvals[foo] += 3.8*(foo + 1);
rvals[foo] += 3.9 * (foo + 1);
}
if (rvals[foo] > 1023.0) {
rvals[foo] = (float)(rand() % 15);
rvals[foo] = (float)(rand() % 25);
}
}
@ -77,7 +77,7 @@ keypad(stdscr, TRUE); /* acces aux touches 'curseur' */
fond_ecran(" Demonstrator ");
demo(90000, 0);
demo(190000, 0);
/*
* plop, on a fini, restaurer la console


Loading…
Cancel
Save