Skip to main content
Arduino

Return to Question

Commonmark migration
Source Link

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][1]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.

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... [1]: http://www.dfrobot.com/wiki/index.php?title=SPI_LCD_Module_%28SKU:DFR0091%29

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][1]. 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.

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... [1]: http://www.dfrobot.com/wiki/index.php?title=SPI_LCD_Module_%28SKU:DFR0091%29

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.

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...

added 2512 characters in body
Source Link
Thijser
  • 173
  • 10

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... [1]: http://www.dfrobot.com/wiki/index.php?title=SPI_LCD_Module_%28SKU:DFR0091%29

Edit having just reuploaded the code again this time the led just remains on all the time. [1]: http://www.dfrobot.com/wiki/index.php?title=SPI_LCD_Module_%28SKU:DFR0091%29

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... [1]: http://www.dfrobot.com/wiki/index.php?title=SPI_LCD_Module_%28SKU:DFR0091%29

added 95 characters in body
Source Link
Thijser
  • 173
  • 10

it stops flashing completely.

Edit having just reuploaded the code again this time the led just remains on all the time. [1]: http://www.dfrobot.com/wiki/index.php?title=SPI_LCD_Module_%28SKU:DFR0091%29

it stops flashing completely.

Edit having just reuploaded the code again this time the led just remains on all the time. [1]: http://www.dfrobot.com/wiki/index.php?title=SPI_LCD_Module_%28SKU:DFR0091%29

added 497 characters in body
Source Link
Thijser
  • 173
  • 10
Loading
Source Link
Thijser
  • 173
  • 10
Loading
lang-cpp

AltStyle によって変換されたページ (->オリジナル) /