Hello everyone.
Im willing to build a queue management system that will display token numbers on different "Counter" having a TV screeen. I2C shall be used to send Token number to 328p ICs each running a TV screen present in front of the counters. This project is in its initial stage, I want to call a function TV.bitmap () which displays a bitmap image file (here, the numbers 0-9). The function requires 3 values: (x,y coordinates of the TV screen, name of the bmp file). These 3 values are generated from another function that determines the digits and their location on screen depending on the value received by pressing a switch. I am stuck at this point, realizing how much more i have to learn the fundamentals of programming.
Thank you earnestly for taking your time and offering of help.
Please see the //information on the code
Here it is:
//Using this program to show numbers sequentially on different TV/screens
#include <TVout.h>
#include <fontALL.h>
#include "no1.h" //bmp files to view larger (higher than maximum font size) digits
#include "no2.h"
#include "no3.h"
#include "no4.h"
#include "no5.h"
#include "no6.h"
#include "no7.h"
#include "no8.h"
#include "no9.h"
#include "no0.h"
#include <Wire.h> // for using i2c to receive [val] which generates the digits
TVout TV;
int val=0, val1; //the input value from sw1 & sw2
int sw1 = 4; //switches
int sw2 = 5;
void generator_ones(); //declaring functions to set position of bmp files in (x,y) axes of tv resolution
void generator_tens(); //each select unit, ten's or hundred's digit which show bmp files in xy position
void generator_huns(); //
void setup() {
TV.begin(PAL, 120,104);
Wire.begin();
pinMode (sw1, INPUT_PULLUP);
pinMode (sw2, INPUT_PULLUP);
}
void loop() {
if (val>0 && val<10) { //For 1 digit display
generator_ones(TV.bitmap()); // *******Is it possible to call function in this manner?********
TV.delay (50);
}
if (val>=10 && val<100) { //for 2 digits display
generator_ones(TV.bitmap());
generator_tens(TV.bitmap()); //TV.bitmap(x,y,digit) x and y is position of bmp, digit is used as a variable to select bmp file
TV.delay (50);
}
if (val>=100) { //for 3 digits display
generator_ones(TV.bitmap());
generator_tens(TV.bitmap());
generator_huns(TV.bitmap());
TV.delay (50);
}
if (digitalRead(sw1) == LOW) //simplest way to receive input value [later upgrade]
val++;
if (digitalRead(sw2) == LOW)
val1++;
}
int *generator_ones(int x, int y, char digit) //not sure about the pointer, it was the final experiment before asking in forum
{ //******how to return these three values inside the TV.bitmap function?*******
unsigned int huns = val/100; //finding out hundred's digit
unsigned int tens = (val-huns*100)/10 ; ////finding out ten's digit
unsigned int ones = val - (huns*100 + tens*10);//finding out one's digit
if ((ones>0) &&(ones<10)) {
if (tens==0 && huns==0) { //for setting the bmp position at (approx) center of my TV screen
x = 42;
y = 30;
}
if (tens>0 && huns ==0) { //for setting the bmp position when there are two digits
x = 62;
y = 30;
}
if (tens>0 && huns >0) { //for setting the bmp position when there are three digits
x = 82;
y = 30;
}
if (ones ==1) // for selecting the bmp
digit = "no1";
if (ones ==2)
digit = "no2";
if (ones ==3)
digit = "no3";
if (ones ==4)
digit = "no4";
if (ones ==5)
digit = "no5";
if (ones ==6)
digit = "no6";
if (ones ==7)
digit = "no7";
if (ones ==8)
digit = "no8";
if (ones ==9)
digit = "no9";
if (ones ==0)
digit = "no0";
}
}
int *generator_huns(int x, int y, char digit) // same function to generate hundred's digit,
{ //set position and return these 3 values (not yet possible)
unsigned int tens = val%10;
unsigned int huns = val%100;
unsigned int ones = val - (huns*100 + tens*10);
if ((huns>0) &&(huns<10)) { //for setting the digit's position on screen
x = 2;
y = 30;
if (huns ==1) // selecting the bmp files
digit = "no1";
if (huns ==2)
digit = "no2";
if (huns ==3)
digit = "no3";
if (huns ==4)
digit = "no4";
if (huns ==5)
digit = "no5";
if (huns ==6)
digit = "no6";
if (huns ==7)
digit = "no7";
if (huns ==8)
digit = "no8";
if (huns ==9)
digit = "no9";
if (huns ==0)
digit = "no0";
}
}
int *generator_tens(int x, int y, char digit) //same function to generate ten's digit
{ //set position on screen and display the bmp digit
unsigned int tens = val%10;
unsigned int huns = val%100;
unsigned int ones = val - (huns*100 + tens*10);
if ((tens>0) &&(tens<10)) {
if (huns == 0) {
x = 22;
y = 30;
}
else {
x = 42;
y = 30;
}
if (tens ==1)
digit = "no1";
if (tens ==2)
digit = "no2";
if (tens ==3)
digit = "no3";
if (tens ==4)
digit = "no4";
if (tens ==5)
digit = "no5";
if (tens ==6)
digit = "no6";
if (tens ==7)
digit = "no7";
if (tens ==8)
digit = "no8";
if (tens ==9)
digit = "no9";
if (tens ==0)
digit = "no0";
}
}
//THANK YOU VERY MUCH for giving your time to read my program. Please share your ideas and help me identify the mistakes and understand the correct way of doing this program. Thank you again.