I posted a few days ago because I was getting an error message about "too many initializers" and some kind folks helped me then. I thought I was all set, because those error messages went away. But somehow, I wasn't paying attention to new warnings that were produced instead.
I am now getting a long series of warnings like this:
C:\Users\tastewar\Documents\Arduino\sketch_jan10a\sketch_jan10a.ino:50:1: warning: narrowing conversion of '16753920l' from 'long int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
C:\Users\tastewar\Documents\Arduino\sketch_jan10a\sketch_jan10a.ino:50:1: warning: large integer implicitly truncated to unsigned type [-Woverflow]
Here is my code which will compile and yield these errors:
#define RED 0x00FF0000
#define GREEN 0x0000FF00
#define BLUE 0x000000FF
#define PURPLE 0x00800080
#define YELLOW 0x00FFFF00
#define ORANGE 0x00FFA500
#define LUNCH ORANGE
#define ASPIRE ORANGE
#define OUTOFCLUSTER ORANGE
typedef struct _Period
{
uint8_t begH;
uint8_t begM;
uint8_t endH;
uint8_t endM;
uint32_t aCol;
uint32_t bCol;
uint32_t cCol;
uint32_t dCol;
} Period;
#define MAX_PERIODS 9
typedef struct _BellSched
{
uint8_t NumPeriods;
Period Periods[MAX_PERIODS];
} BellSched;
typedef struct _SingleDay
{
uint16_t Y;
uint8_t M;
uint8_t D;
const BellSched* dayType;
} SingleDay;
const PROGMEM BellSched NormalDay[]=
{
9,
{ 8, 0, 8,50, OUTOFCLUSTER, RED, OUTOFCLUSTER, YELLOW},
{ 8,52, 9,40, RED, YELLOW, YELLOW, OUTOFCLUSTER},
{ 9,42, 9,52, ASPIRE, ASPIRE, ASPIRE, ASPIRE},
{ 9,54,10,42, YELLOW, OUTOFCLUSTER, RED, RED},
{10,44,11,32, GREEN, OUTOFCLUSTER, BLUE, GREEN},
{11,34,12,23, OUTOFCLUSTER, BLUE, GREEN, PURPLE},
{12,25,12,46, LUNCH, LUNCH, LUNCH, LUNCH},
{12,48,13,36, BLUE, PURPLE, PURPLE, OUTOFCLUSTER},
{13,38,14,26, PURPLE, GREEN, OUTOFCLUSTER, BLUE},
};
const PROGMEM BellSched ER1300[]=
{
8,
{ 8, 0, 8,37, OUTOFCLUSTER, RED, OUTOFCLUSTER, YELLOW},
{ 8,39, 9,16, RED, YELLOW, YELLOW, OUTOFCLUSTER},
{ 9,18, 9,55, YELLOW, OUTOFCLUSTER, RED, RED},
{ 9,57,10,34, GREEN, OUTOFCLUSTER, BLUE, GREEN},
{10,36,11,12, BLUE, PURPLE, PURPLE, OUTOFCLUSTER},
{11,14,12, 0, OUTOFCLUSTER, BLUE, GREEN, PURPLE},
{12, 2,12,22, LUNCH, LUNCH, LUNCH, LUNCH},
{12,24,13, 0, PURPLE, GREEN, OUTOFCLUSTER, BLUE},
};
// days not present are either weekend days or holidays
const PROGMEM SingleDay TheCalendar[]=
{
{2018,9,4,NormalDay},
{2018,9,5,NormalDay},
{2018,9,6,NormalDay},
{2018,9,7,NormalDay},
{2018,9,11,NormalDay},
{2018,9,12,NormalDay},
{2018,9,13,NormalDay},
{2018,9,14,NormalDay},
{2018,9,17,NormalDay},
{2018,9,18,ER1300},
{2018,9,20,NormalDay},
{2018,9,21,NormalDay},
};
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
OK, so this suggests to me that the compiler and I are not on the same page. It's talking about my color definitions being truncated from 32 to 8 bits, but the structure definition clearly (well, to me ) has them as 32 bits. So, my belief is that somehow, the initializers I have provided aren't getting mapped into the structures the way I think they should.
Also, while the solution I was given was to add the [] after my variable names, which did have the immediately desired effect, something tells me this still isn't right, because it states that my variables are arrays, and they're not. They shouldn't be arrays of BellSched's -- each variable should be a single BellSched.
But of course, if I remove the brackets, I'm back to the too many initializers problem.
What am I doing wrong??