Ошибка при проверке и компиляции

igor.aksenov
Offline
Зарегистрирован: 16.02.2015

Здравствуйте, проект при проверке и компиляции выдает ошибку 

Arduino: 1.6.0 (Windows 7), Плата"Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Build options changed, rebuilding all

C:\Program Files\Arduino\libraries\TFTLCD\glcdfont.c:13:22: error: variable 'font' must be const in order to be put into read-only section by means of '__attribute__((progmem))'
 static unsigned char font[] PROGMEM = {
                      ^

на строку в файле "glcdfont.c" библиотеки "TFTLCD "

как я понял, та самая строка: 

static unsigned char font[] PROGMEM = {

и не хватает после "static" слова "const"

Когда его добавляю, проверка и компиляция проходит отлично, но график на экране не меняется (т.е. статичен), 

Подсобите советом или делом пожалуйста

Datak
Offline
Зарегистрирован: 09.10.2014

Всё правильно исправили.

Дальше ошибка в чём-то другом, но про это тут ничего не написано, поэтому вряд ли кто-то что-то подскажет. :)

igor.aksenov
Offline
Зарегистрирован: 16.02.2015

Сам проект, это измерение вибрации, есть 2 платы, на одной измерительный элемент + радиоприемопередатчик; на 2-ой радиоприемопередатчик + TFTLCD shield для показаний. Когда заливаю с этой const график не меняется, только 2 вертикальные черты, вот я и подумал, быть может дело в этой const.

P.S. вчера скачал arduino-1.0.4, в ней проверка проходит без ошибки, попробую сегодня залить

nevkon
Offline
Зарегистрирован: 20.01.2015

Поставил 1.6.0, такой ошибки не наблюдаю. Единственное у меня библиотека звучит почему-то как просто TFT. Наверное я скачивал позже и там уже пофиксено.

igor.aksenov
Offline
Зарегистрирован: 16.02.2015

После сегодняшних умственных "исканий" понял что дело еще и в том, что я шилд дисплея ставлю на мегу, а шилд заточен под уно. Ну что же, буду разбираться

igor.aksenov
Offline
Зарегистрирован: 16.02.2015

Мож подсобите, посмотрите код, ставлю на мегу - получаю перевернутое изображение (зеркально)


#include <SPI.h>
#include <digitalWriteFast.h>
#include <iBoardRF24.h>
#include <printf.h>
#include <Adafruit_GFX.h>    // Core graphics library
#include <SWTFT.h> // Hardware-specific library
#include <TouchScreen.h>

#define YP A1  // must be an analog pin, use "An" notation!
#define XM A2  // must be an analog pin, use "An" notation!
#define YM 7   // can be a digital pin
#define XP 6   // can be a digital pin

#define TS_MINX 150
#define TS_MINY 120
#define TS_MAXX 920
#define TS_MAXY 940

#define BOXSIZE 40
#define PENRADIUS 3

#define	BLACK   0x0000
#define	BLUE    0x001F
#define	RED     0xF800
#define	GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF

SWTFT tft;
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);


//iBoardRF24(cepin, cspin, mosi_pin, miso_pin, sck_pin, irq_pin):
const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };

typedef struct{         
  unsigned long ms;
  unsigned long avgvalues; 
  unsigned long nchanges;
 // unsigned long nscan;
  unsigned long n;
}
RFMsg;

typedef struct{         
  unsigned int y;
  int value; 
}
GPoint;

unsigned long testTriangles();
unsigned long prevMicro=0;
unsigned long prevN=0;
unsigned long currentMillis;
unsigned long textInterval = 1000;
unsigned long prevtextMills = 0;

unsigned long statsec_N=0;
unsigned long statsec_SumVal=0;
unsigned long statsec_NAct=0;
unsigned long stat_MaxNValues=0;
unsigned long stat_scrMaxNValues=0;
unsigned long stat_avgCnt=0;


int w = 0;
int h = 0;
float curpos = 0;
float prevpos = 0;
unsigned long  maxvalue = 1024;
float ko = 0;
unsigned int topline = 1;
unsigned int bottomline = 15;
int viewType = 2;
//GPoint scr[320];

void DrawCountAmp(RFMsg msg);
void DrawG(int y);
void DrawAmpOnly(RFMsg msg,int ystart,int ystop);
void DrawCountOnly(RFMsg msg,int ystart,int ystop);

void setup(void)
{
  tft.reset();
  uint16_t identifier = tft.readID();
  tft.begin(identifier);
  tft.setRotation(3);  
  
  w = tft.width(),
  h = tft.height();  
  
  
  delay(100);
  Serial.begin(57600);
  delay(100);
  printf_begin();
  printf("\n\rRF24/examples/GettingStarted/\n\r");
  delay(100);
  printf("*** \n\r");
  radio.begin();
  // optionally, increase the delay between retries & # of retries
  radio.setRetries(15,15);
  // optionally, reduce the payload size.  seems to
  // improve reliability
  radio.setPayloadSize(sizeof(RFMsg));

    radio.openWritingPipe(pipes[1]);
    radio.openReadingPipe(1,pipes[0]);
  radio.startListening();
  radio.printDetails();
  //radio.setAutoAck(false);
  //testTriangles();
  tft.fillScreen(BLACK);
  unsigned long start = micros();
  ko = ((float)h-(float)bottomline) / (float)maxvalue;
  
}



void loop(void)
{
  Point p = ts.getPoint();
  pinMode(XM, OUTPUT);
  pinMode(YP, OUTPUT);
  if (p.z>0) {
   viewType++;
   if (viewType>2) viewType=0; 
   tft.fillScreen(BLACK);
   curpos=0; 
   delay(200);
  }
  
  
  
    if ( radio.available() )
    {
      // Dump the payloads until we've gotten everything
      RFMsg msg;
      bool done = false;
      //1 мксек= 1 / 1 000 000 сек
      while (!done)
      {
        currentMillis = micros(); 
        // Fetch the payload, and see if this was the last one.
        done = radio.read( &msg, sizeof(RFMsg) );
        
        //curpos++;
        curpos = curpos + (float)msg.ms / 100000;
        
        if (curpos>=w) {
         curpos=0;
   
         if (stat_scrMaxNValues>stat_MaxNValues*2) {
           stat_scrMaxNValues=stat_MaxNValues+(stat_MaxNValues%4);
         }

         stat_MaxNValues=0;
         
         
         //stat_MaxNValues = stat_AllMaxNValues;
         //tft.drawLine(curpos, h-bottomline, curpos, 0, BLUE);
        }
        
        if (msg.nchanges>stat_MaxNValues) 
        {
           stat_MaxNValues = msg.nchanges;
        }

       if (currentMillis - prevtextMills > textInterval*1000) {
               tft.drawFastVLine(curpos, topline, h-topline-bottomline, 0x0007);
       }
        if (viewType==0) {        
          DrawAmpOnly(msg, topline,h-bottomline);
        }
        if (viewType==1) {        
          DrawCountOnly(msg, topline,h-bottomline);
        }
        if (viewType==2) {        
          int seredina = (h-topline-bottomline)/2;
          DrawAmpOnly(msg, topline,seredina);
          DrawCountOnly(msg, seredina+1,h-bottomline);
        }

       statsec_N++;
       statsec_SumVal=statsec_SumVal+msg.avgvalues;
       statsec_NAct=statsec_NAct+msg.nchanges;

       //stat_MaxNValues=statsec_NAct+msg.nchanges;

       if (currentMillis - prevtextMills > textInterval*1000) {
              tft.setCursor(10, h-bottomline+4);
      
              if ( msg.n-prevN>1 ) {
                tft.fillRect(0, h-bottomline, w, bottomline, MAGENTA);
                 tft.print("E:");
                 tft.print(msg.n-prevN);
                 tft.print(" ");
         
              } else {       
                tft.fillRect(0, h-bottomline, w, bottomline, BLUE);
              }
      
              tft.setTextColor(WHITE);  
              tft.setTextSize(1);
              tft.print("INT:");
              tft.setTextColor(YELLOW);  
              tft.print(msg.ms);
              tft.setTextColor(WHITE);  
              tft.print(" VAL:");
              tft.setTextColor(YELLOW);  
              tft.print(msg.avgvalues);
              tft.setTextColor(WHITE);  
              tft.print(" CNT:");
              tft.setTextColor(YELLOW);  
              tft.print(statsec_NAct%statsec_N);
              tft.setTextColor(WHITE);  
              tft.print(" MAX:");
              tft.setTextColor(YELLOW);  
              tft.print(stat_MaxNValues);
              
              /*
              tft.print(" Y:");
              tft.print(p.y);
              tft.print(" X:");
              tft.print(p.x);
              tft.print(" Z:");
              tft.print(p.z);
              */
              
               prevtextMills = currentMillis;
               
               statsec_N=0;
               statsec_SumVal=0;
               statsec_NAct=0;
               

               
       }
       


        prevpos = curpos;
        prevN = msg.n;
        
        //tft.drawLine(curpos+1, h-bottomline, curpos+1, 0, BLUE);
        //tft.drawLine(curpos, h-bottomline, curpos, y, YELLOW);
        //printf("MS:%lu  RV: %i Y:%f KO:%f H:%i MAX:%i",msg.ms,msg.value,y,h / maxvalue,h,maxvalue);
        //printf("\n\r");
      }
      //radio.stopListening();

      // Send the final one back.
      //radio.write( &got_time, sizeof(unsigned long) );
      //printf("Sent response.\n\r");
      //radio.startListening();
    }
  }


unsigned long testTriangles() {
  unsigned long start;
  int           n, i, cx = tft.width()  / 2 - 1,
                      cy = tft.height() / 2 - 1;

  tft.fillScreen(BLACK);
  n     = min(cx, cy);
  start = micros();
  for(i=0; i<n; i+=5) {
    tft.drawTriangle(
      cx    , cy - i, // peak
      cx - i, cy + i, // bottom left
      cx + i, cy + i, // bottom right
      tft.color565(0, 0, i));
  }
  return micros() - start;
}

void DrawAmpOnly(RFMsg msg,int ystart,int ystop) {
          float ko = ((float)ystop-(float)ystart) / (float)maxvalue;
          float y = msg.avgvalues * ko; //(float)(msg.value * ko);
          int he = ystop-ystart;
          DrawCursor(ystart,ystop);
          tft.drawFastVLine(curpos, ystart+(he-y), y, GREEN);
}

void DrawCountOnly(RFMsg msg,int ystart,int ystop) 
{
          int he = ystop-ystart;
          if (msg.nchanges>stat_scrMaxNValues) 
          {
             stat_scrMaxNValues = msg.nchanges+ (msg.nchanges%3);
             tft.drawFastVLine(curpos-1, ystart, he, YELLOW);
          }
          float ko = ((float)ystop-(float)ystart) / (float)stat_scrMaxNValues;
          float y = msg.nchanges * ko; //(float)(msg.value * ko);
          DrawCursor(ystart,ystop);
          tft.drawFastVLine(curpos, ystart+(he-y), y, RED);
}

void DrawCursor(int ystart,int ystop) {
          int he = ystop-ystart;
          tft.drawFastVLine(curpos+1, ystart, he, BLACK);
          tft.drawFastVLine(curpos+2, ystart, he, MAGENTA);
          tft.drawFastVLine(curpos+3, ystart, he, BLACK);
}

 

nevkon
Offline
Зарегистрирован: 20.01.2015

А по какой оси инверсия? В принципе можете сами подправить программу инвертировав нужную ось.

igor.aksenov
Offline
Зарегистрирован: 16.02.2015

вот фото моего "зазеркалья" - там, как я понял полная "инверсия"

nevkon
Offline
Зарегистрирован: 20.01.2015

SWTFT что за библиотека? Может поменять на стандартную какую-нибудь? Не удивлюсь если она тупит.

igor.aksenov
Offline
Зарегистрирован: 16.02.2015

Не подскажите стандартную?

nevkon
Offline
Зарегистрирован: 20.01.2015

Обычно вроде используют UTFT. На этом форуме довольно активно обсуждается подключение подобных экранов.

Например тут: http://arduino.ru/forum/apparatnye-voprosy/tft-35-i-arduino