Fonctionne avec 4 TC et choix graphe par potar
This commit is contained in:
parent
a40ce78fcd
commit
24e5d2a74d
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
|
@ -0,0 +1,50 @@
|
|||
//---------------------------------------------------------------------------
|
||||
// glcd bitmap header created with bmp2glcd v2.0
|
||||
// The glcd bitmap data contained in this file is in a format
|
||||
// suitable for use by openGLCD.
|
||||
// It contains embedded width and height format information.
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#ifndef _logo_H
|
||||
#define _logo_H
|
||||
|
||||
GLCDBMAPDECL(logo) = {
|
||||
40, // width
|
||||
40, // height
|
||||
|
||||
// page 0 (lines 0-7)
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x80,0x80,0x80,0x80,0x80,0xc0,
|
||||
0xc0,0xc0,0xc0,0x80,0x80,0x80,0x80,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0xe0,
|
||||
0xf0,0xf8,0xfc,0x7e,0x3e,0x3e,0x1c,0x08,
|
||||
|
||||
// page 1 (lines 8-15)
|
||||
0x00,0x00,0xc0,0xf0,0xf8,0xfc,0xfe,0x7e,
|
||||
0x3f,0x1f,0x0f,0x0f,0x07,0x07,0x07,0x07,
|
||||
0x07,0x07,0x07,0x07,0x07,0x07,0x0f,0x1f,
|
||||
0x1f,0x7f,0xfe,0xfc,0xf8,0xf0,0xc1,0x01,
|
||||
0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
|
||||
// page 2 (lines 16-23)
|
||||
0xf8,0xff,0xff,0xff,0xff,0x0f,0x01,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
|
||||
0xc0,0xc0,0xc1,0xc1,0xc1,0xc1,0xc1,0xc0,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
|
||||
// page 3 (lines 24-31)
|
||||
0x07,0x7f,0xff,0xff,0xff,0xfc,0xe0,0x80,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
|
||||
0x03,0x03,0xc3,0xff,0xff,0xff,0xff,0xff,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
|
||||
// page 4 (lines 32-39)
|
||||
0x00,0x00,0x00,0x03,0x07,0x0f,0x1f,0x1f,
|
||||
0x3f,0x3e,0x7c,0x7c,0x78,0xf8,0xf8,0xf8,
|
||||
0xf8,0xf8,0xf8,0x78,0x78,0x78,0x3c,0x3c,
|
||||
0x1e,0x1f,0x0f,0x07,0x7f,0x7f,0x7f,0x7f,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
|
||||
};
|
||||
#endif // /mnt/pi/users/grouch/Arduino/quadTC/logo_H
|
138
quadTC.ino
138
quadTC.ino
|
@ -1,20 +1,24 @@
|
|||
//#include <SPI.h>
|
||||
#include <openGLCD.h>
|
||||
#include "logo.h"
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// CONSTANTES
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
#define MAX6675_CS1 13
|
||||
#define MAX6675_CS2 8
|
||||
#define MAX6675_CS3 8
|
||||
#define MAX6675_CS4 8
|
||||
#define VERSION "20180415"
|
||||
#define MAX6675_CS0 13
|
||||
#define MAX6675_CS1 12
|
||||
#define MAX6675_CS2 3
|
||||
#define MAX6675_CS3 2
|
||||
#define MAX6675_SO 1
|
||||
#define MAX6675_SCK 19
|
||||
#define POTAR_PIN A7
|
||||
|
||||
#define LEN_PLOT 100
|
||||
|
||||
const byte X0Graph = 92;
|
||||
const int T_REFRESH = 500;
|
||||
const int T_SWITCH = 100;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// CLASSE PLOT
|
||||
|
@ -29,9 +33,6 @@ class Plot{
|
|||
int y_max;
|
||||
|
||||
Plot(){
|
||||
for (int i = 0 ; i<LEN_PLOT ; i++){
|
||||
y[i] = NAN;
|
||||
}
|
||||
}
|
||||
|
||||
void SetScale (int mini, int maxi){
|
||||
|
@ -42,23 +43,23 @@ class Plot{
|
|||
void AutoScale(){
|
||||
int mini = 1024;
|
||||
int maxi = 0;
|
||||
for (int i = 0 ; i<LEN_PLOT ; i++){
|
||||
for (int i = 0 ; i<LEN_PLOT ; i++){ // recherche min et max des points connus
|
||||
if (y[i]<mini){mini = y[i];}
|
||||
if (y[i]>maxi){maxi = y[i];}
|
||||
}
|
||||
|
||||
int range = (maxi-mini);
|
||||
|
||||
if (range < 64){
|
||||
if (range < 64){ // si étendue faible -> graphe de 64 points
|
||||
y_min = (maxi + mini)/ 2 - 31;
|
||||
y_min = max(0, y_min);
|
||||
y_max = y_min + 64;
|
||||
} else {
|
||||
} else { // sinon graphe +20% de l'étendue
|
||||
y_min = mini - 0.2*range;
|
||||
y_min = max(0, y_min);
|
||||
y_max = maxi + 0.2*range;
|
||||
}
|
||||
y_max = min(1024, y_max);
|
||||
y_max = min(1024, y_max); // on borne à la valeur max du MAX6675
|
||||
}
|
||||
|
||||
void Push(int val){
|
||||
|
@ -72,10 +73,9 @@ class Plot{
|
|||
GLCD.SetPixels(x0, y1, x1, y0, PIXEL_OFF);
|
||||
for (int i = 0 ; i<LEN_PLOT ; i++){
|
||||
//int u = map(i, 0, LEN_PLOT, x0, x1);
|
||||
int u = i+X0Graph;
|
||||
int v = map(y[i], y_min, y_max, y0 , y1) ;
|
||||
|
||||
GLCD.SetDot(u ,v ,PIXEL_ON);
|
||||
int u = i+X0Graph;
|
||||
int v = map(y[i], y_min, y_max, y0 , y1) ;
|
||||
GLCD.SetDot(u ,v ,PIXEL_ON);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -85,13 +85,14 @@ class Plot{
|
|||
//----------------------------------------------------------------------------------
|
||||
|
||||
gText t[4];
|
||||
gText a;
|
||||
gText curseur[4];
|
||||
gText y[3];
|
||||
|
||||
Plot p1;
|
||||
Plot p2;
|
||||
Plot p3;
|
||||
Plot p4;
|
||||
Plot p[4];
|
||||
|
||||
unsigned long pm_switch;
|
||||
unsigned long pm_refresh;
|
||||
byte plot_index = 0;
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// CODE
|
||||
|
@ -115,25 +116,31 @@ double readTC(byte CSpin) {
|
|||
}
|
||||
|
||||
void setup() {
|
||||
pinMode(MAX6675_CS0, OUTPUT);
|
||||
pinMode(MAX6675_CS1, OUTPUT);
|
||||
pinMode(MAX6675_CS2, OUTPUT);
|
||||
pinMode(MAX6675_CS3, OUTPUT);
|
||||
pinMode(MAX6675_CS4, OUTPUT);
|
||||
pinMode(MAX6675_SO, INPUT);
|
||||
pinMode(MAX6675_SCK, OUTPUT);
|
||||
GLCD.Init();
|
||||
t[0].DefineArea(2, 3,6,1,cp437font8x8);
|
||||
t[1].DefineArea(2,20,6,1,cp437font8x8);
|
||||
t[2].DefineArea(2,37,6,1,cp437font8x8);
|
||||
t[3].DefineArea(2,53,6,1,cp437font8x8);
|
||||
|
||||
a.DefineArea(55,3,1,1,cp437font8x8);
|
||||
a.Printf("<");
|
||||
|
||||
t[0].Printf("A 900");
|
||||
t[1].Printf("B 956");
|
||||
t[2].Printf("C 848");
|
||||
t[3].Printf("D 123");
|
||||
GLCD.DrawBitmap(logo, 15,7);
|
||||
|
||||
gText titre;
|
||||
titre.DefineArea(100,10,15,1,cp437font8x8);
|
||||
titre.Printf("quadTC");
|
||||
titre.DefineArea(90,27,30,1,Callibri11);
|
||||
titre.Printf("by The Grouch'");
|
||||
titre.DefineArea(100,41,30,1,Callibri11);
|
||||
titre.Printf("Tooling Co.");
|
||||
titre.DefineArea(158,57,30,1,Wendy3x5);
|
||||
titre.Printf(VERSION);
|
||||
delay(2000);
|
||||
|
||||
GLCD.ClearScreen();
|
||||
|
||||
curseur[0].DefineArea(55,3,1,1,cp437font8x8);
|
||||
curseur[0].Printf("<");
|
||||
GLCD.DrawVLine(X0Graph-1,0,64);
|
||||
GLCD.DrawHLine(X0Graph-2,0,3);
|
||||
GLCD.DrawHLine(X0Graph-2,32,3);
|
||||
|
@ -141,16 +148,57 @@ void setup() {
|
|||
}
|
||||
|
||||
void loop() {
|
||||
int tc = readTC(MAX6675_CS1);
|
||||
t[0].Printf("A %4d",tc);
|
||||
p1.Push(tc);
|
||||
p1.AutoScale();
|
||||
y[0].DefineArea(73, 1,4,1,Wendy3x5);
|
||||
y[1].DefineArea(73,58,4,1,Wendy3x5);
|
||||
y[2].DefineArea(73,30,4,1,Wendy3x5);
|
||||
y[0].Printf("%4d",p1.y_max);
|
||||
y[1].Printf("%4d",p1.y_min);
|
||||
y[2].Printf("%4d",(p1.y_min+p1.y_max)/2);
|
||||
p1.Trace(X0Graph , 191 , 63, 0);
|
||||
delay(200);
|
||||
unsigned long cm = millis();
|
||||
|
||||
if ((cm - pm_refresh) > T_REFRESH){
|
||||
t[0].DefineArea(2, 3,6,1,cp437font8x8);
|
||||
t[1].DefineArea(2,20,6,1,cp437font8x8);
|
||||
t[2].DefineArea(2,37,6,1,cp437font8x8);
|
||||
t[3].DefineArea(2,53,6,1,cp437font8x8);
|
||||
|
||||
int tc = readTC(MAX6675_CS0); // Lecture TC
|
||||
t[0].Printf("A %4d",tc); // Affichage valeur
|
||||
p[0].Push(tc); // Stockage valeur pour graphe
|
||||
|
||||
tc = readTC(MAX6675_CS1);
|
||||
t[1].Printf("B %4d",tc);
|
||||
p[1].Push(tc);
|
||||
|
||||
tc = readTC(MAX6675_CS2);
|
||||
t[2].Printf("C %4d",tc);
|
||||
p[2].Push(tc);
|
||||
|
||||
tc = readTC(MAX6675_CS3);
|
||||
t[3].Printf("D %4d",tc);
|
||||
p[3].Push(tc);
|
||||
|
||||
y[0].DefineArea(73, 1,4,1,Wendy3x5); // PM plantage avr-gcc si pas fait à chaque loop !?§
|
||||
y[1].DefineArea(73,58,4,1,Wendy3x5);
|
||||
y[2].DefineArea(73,30,4,1,Wendy3x5);
|
||||
|
||||
y[0].Printf("%4d",p[plot_index].y_max);
|
||||
y[1].Printf("%4d",p[plot_index].y_min);
|
||||
y[2].Printf("%4d",(p[plot_index].y_min+p[plot_index].y_max)/2);
|
||||
|
||||
p[plot_index].AutoScale();
|
||||
p[plot_index].Trace(X0Graph , 191 , 63, 0);
|
||||
pm_refresh = cm;
|
||||
}
|
||||
|
||||
if ((cm - pm_switch) > T_SWITCH){
|
||||
//plot_index++;
|
||||
//if (plot_index>3){plot_index=0;}
|
||||
plot_index = map(analogRead(POTAR_PIN)+50, 0, 1023, 0, 3);
|
||||
//y[2].Printf("%4d",analogRead(POTAR_PIN));
|
||||
curseur[0].DefineArea(55,3,1,1,cp437font8x8);
|
||||
curseur[1].DefineArea(55,20,1,1,cp437font8x8);
|
||||
curseur[2].DefineArea(55,37,1,1,cp437font8x8);
|
||||
curseur[3].DefineArea(55,53,1,1,cp437font8x8);
|
||||
for (byte i=0; i<4;i++){
|
||||
if (i != plot_index){curseur[i].ClearArea();}}
|
||||
curseur[plot_index].Printf("<");
|
||||
|
||||
pm_switch = cm;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue