I have the following code:
#include "LCD12864RSPI.h"
#include "DFrobot_bmp.h"
#include "DFrobot_char.h"
#define AR_SIZE( a ) sizeof( a ) / sizeof( a[0] )
unsigned char wangzhi[]=" www.DFRobot.com ";
unsigned char fused[1024];
void setup()
{
pinMode(11, OUTPUT);
for(int i=0;i<4;i++){
digitalWrite(11,HIGH);
delay(1000);
digitalWrite(11,LOW);
delay(1000);
}
LCDA.initDriverPin(2,7,10);
LCDA.Initialise(); // INIT SCREEN
}
unsigned char* fuse3(unsigned char* a ,unsigned char* b,unsigned char* c){
int i=0;
int ac=0;//a counter
int bc=0; //b counter
int cc=0;//c counter
for(int n=0;n<64;n++){
for(int k=0;k<5;k++){
fused[i]=a[ac];
ac++;
i++;
}
for(int k=0;k<5;k++){
fused[i]=b[bc];
bc++;
i++;
}
for(int k=0;k<5;k++){
fused[i]=c[cc];
cc++;
i++;
}
fused[i]=0x00;
i++;
}
return fused;
}
unsigned char* getMatch(int input){
input = input & 0x000f;
switch (input){
case 0: return g0;
case 1: return g1;
case 2: return g2;
case 3: return g3;
case 4: return g4;
case 5: return g5;
case 6: return g6;
case 7: return g7;
case 8: return g8;
case 9: return g9;
case 10: return plus;
case 11: return minus;
case 12: return times;
case 13: return g1;
case 14: return g1;
case 15: return g1;
default: return g1;
}
}
void displayfuse(int number){
// LCDA.DrawFullScreen(fuse3(getMatch(1),getMatch(2),getMatch(3)));
}
void loop(){
displayfuse(0x1234);
}
This code is a stripped version of the code I need to run to get a bigger project working. But if it somewhat works than the setup should begin by flashing a LED 4 times before continuing. Currently this works. However as you can see I have commented out the line LCDA.DrawFullScreen(fuse3(getMatch(1),getMatch(2),getMatch(3)));
. uncommenting this line causes the LED's to flash continuously rather then just 4 times. The library I'm using can be found here. Does anybody know what is going on? To me the first few lines of a program can be affected by a change somewhere this deep inside the code is a form of dark magic.
Weirdly when I change the setup to the following: void setup()
{
pinMode(11, OUTPUT);
for(int i=0;i<15;i++){
digitalWrite(11,HIGH);
delay(100);
digitalWrite(11,LOW);
delay(100);
}
for(int i=0;i<4;i++){
digitalWrite(11,HIGH);
delay(1000);
digitalWrite(11,LOW);
delay(1000);
}
LCDA.initDriverPin(2,7,10);
LCDA.Initialise(); // INIT SCREEN
}
it stops flashing completely.
Edit having just reuploaded the code again this time the led just remains on all the time.
edit edit Now with the following code:
#include "LCD12864RSPI.h"
#include "DFrobot_bmp.h"
#include "DFrobot_char.h"
unsigned char fuse[1024];
void setup()
{
LCDA.initDriverPin(2,7,10);
LCDA.Initialise(); // INIT SCREEN
pinMode(11, OUTPUT);
digitalWrite(11,HIGH);
}
unsigned char* fuse3(unsigned char* a ,unsigned char* b,unsigned char* c){
unsigned char* fused =(unsigned char*)malloc(sizeof(char)*1024);
int i=0;
int ac=0;//a counter
int bc=0; //b counter
int cc=0;//c counter
for(int n=0;n<64;n++){
for(int k=0;k<5;k++){
fused[i]=a[ac];
ac++;
i++;
}
for(int k=0;k<5;k++){
fused[i]=b[bc];
bc++;
i++;
}
for(int k=0;k<5;k++){
fused[i]=c[cc];
cc++;
i++;
}
fused[i]=0x00;
i++;
}
return fused;
}
unsigned char* getMatch(int input){
input = input & 0x000f;
switch (input){
case 0: return g0;
case 1: return g1;
case 2: return g2;
case 3: return g3;
case 4: return g4;
case 5: return g5;
case 6: return g6;
case 7: return g7;
case 8: return g8;
case 9: return g9;
case 10: return plus;
case 11: return minus;
case 12: return times;
case 13: return g1;
case 14: return g1;
case 15: return g1;
default: return g1;
}
}
void displayfuse(int number){
LCDA.CLEAR();
delay(100);
int mask1 = 0xF000;
int mask2 = 0x0F00;
int mask3 = 0x00F0;
int firstnumber = number&mask1>>12;
int operation = number&mask2>>8;
int secondnumber= number&mask3>>4;
LCDA.DrawFullScreen(fuse3(getMatch(firstnumber),getMatch(operation),getMatch(secondnumber)));
delay(5000);
}
void loop(){
displayfuse(0x1234);
delay(1000)
}
This causes the led to not turn on but moving the lines where I make pin 11 output and high one up (beyond the LCDA.Initialise(); // INIT SCREEN
) then the led will turn on. It can also be turned on by commenting out the LCDA.DrawFullScreen(fuse3(getMatch(firstnumber),getMatch(operation),getMatch(secondnumber)));
line.
Magic is happening...