Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: Display issues: :Adding main connector files to library gives implicitly deleted

  1. #1
    Senior Member Duhjoker's Avatar
    Join Date
    Aug 2016
    Posts
    431

    Display issues: :Adding main connector files to library gives implicitly deleted

    hi guys!!!

    ok to catch up.... im in the process of using a teensy3.6 and an ili9341 tft to create a teensy game console that includes a super easy library for making your own games. its based on Gamebuino that as of right now uses an uno and a nokia 5110 lcd. so im adding color and resolution.

    I started working on the ili93xx master to add the bits needed to use it for gaming and I finally got it going and looking solid once I added the buffer and set frame rate functions .

    so any way I have everything running great but when I add the main files to that connects everything I get an implicitly denied error. I cant remember having this error before so I have no idea what to do.

    here are the errors...

    Code:
    Arduino: 1.8.0 (Windows 7), TD: 1.34, Board: "Teensy 3.6, Serial, 180 MHz, Fast, US English"
    
    basicSetup:7: error: use of deleted function 'Gamebuino::Gamebuino()'
     Gamebuino gb;
    
               ^
    
    In file included from C:\Users\duhjoker\Desktop\basicSetup\basicSetup.ino:5:0:
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_3/Gamebuino.h:38:7: note: 'Gamebuino::Gamebuino()' is implicitly deleted because the default definition would be ill-formed:
    
     class Gamebuino {
    
           ^
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_3/Gamebuino.h:38:7: error: no matching function for call to 'Display::Display()'
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_3/Gamebuino.h:38:7: note: candidates are:
    
    In file included from C:\Users\duhjoker\Desktop\basicSetup\basicSetup.ino:2:0:
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_3/DisplayRGB.h:194:3: note: Display::Display(uint8_t, uint8_t, uint8_t, uint8_t, uint8_t)
    
       Display(const uint8_t cspin,const uint8_t dcpin,const uint8_t rstpin=255,const uint8_t mosi=11,const uint8_t sclk=13);
    
       ^
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_3/DisplayRGB.h:194:3: note:   candidate expects 5 arguments, 0 provided
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_3/DisplayRGB.h:189:7: note: constexpr Display::Display(const Display&)
    
     class Display : public Print {
    
           ^
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_3/DisplayRGB.h:189:7: note:   candidate expects 1 argument, 0 provided
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_3/DisplayRGB.h:189:7: note: constexpr Display::Display(Display&&)
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_3/DisplayRGB.h:189:7: note:   candidate expects 1 argument, 0 provided
    
    basicSetup: In function 'void setup()':
    basicSetup:228: error: 'display' was not declared in this scope
       errorCode = display.getErrorCode();
    
                   ^
    
    use of deleted function 'Gamebuino::Gamebuino()'
    
    This report would have more information with
    "Show verbose output during compilation"
    option enabled in File -> Preferences.
    ok so basically the gamebuino file has all the class defines to use in the sketches like

    Display display ;
    Buttons buttons ;

    it also carries the popups for dialog, collision and menu stuff that ties it all together. all I should have had to do was drop it inand it work. ive added this file to a display library before and not had the problem. I checked the others too before posting but I have no clue.

    here is the gamebuino.h

    Code:
     *
     * You should have received a copy of the GNU Lesser General Public License
     * along with this program.  If not, see <http://www.gnu.org/licenses/>
     */
    
    #ifndef GAMEBUINO_H
    #define	GAMEBUINO_H
    
    #include <Arduino.h>
    #include <avr/pgmspace.h>
    #include <avr/sleep.h>
    #include "settings.c"
    //#include "Backlight.h" //duhjoker use setBacklight()
    #include "DisplayRGB.h"
    #include "Buttons.h"
    #include "Battery.h"
    //#include "Sound.h"
    
    #define load_game (*((void(*)(const char* filename))(0x7ffc/2)))
    #define write_flash_page (*((void(*)(const char * page, unsigned char * buffer))(0x7ffa/2)))
    
    #define wrap(i, imax) ((imax+i)%(imax))
    
    class Gamebuino {
    public:
       Backlight backlight;
       Buttons buttons;
       Battery battery;
       //Sound sound;
       Display display;
    
        void begin();
    	void titleScreen(const __FlashStringHelper* name, const uint8_t *logo);
    	void titleScreen(const __FlashStringHelper* name);
    	void titleScreen(const uint8_t* logo);
        void titleScreen();
        boolean update();
    	uint8_t startMenuTimer;
        uint32_t frameCount;
        void setFrameRate(uint8_t fps);
    	void pickRandomSeed();
    	
    	uint8_t getCpuLoad();
        uint16_t getFreeRam();
        uint16_t frameDurationMicros;
        uint32_t frameStartMicros, frameEndMicros;
        
        int8_t menu(const char* const* items, uint8_t length);
        void keyboard(char* text, uint8_t length);
        void popup(const __FlashStringHelper* text, uint8_t duration);
    	//void adjustVolume();
    	void changeGame();
    	boolean settingsAvailable();
    	void readSettings();
    	void getDefaultName(char* string);
    	
    	boolean collidePointRect(int16_t x1, int16_t y1 ,int16_t x2 ,int16_t y2, int16_t w, int16_t h);
    	boolean collideRectRect(int16_t x1, int16_t y1, int16_t w1, int16_t h1 ,int16_t x2 ,int16_t y2, int16_t w2, int16_t h2);
        boolean collideBitmapBitmap(int16_t x1, int16_t y1, const uint8_t* b1, int16_t x2, int16_t y2, const uint8_t* b2);
    
    	
    private:
        uint8_t timePerFrame;
        uint32_t nextFrameMillis;
        void updatePopup();
        const __FlashStringHelper* popupText;
        uint8_t popupTimeLeft;
        void displayBattery();
    };
    
    #endif	/* GAMEBUINO_H */
    the .cpp

    Code:
     *
     * You should have received a copy of the GNU Lesser General Public License
     * along with this program.  If not, see <http://www.gnu.org/licenses/>
     */
    
    #ifndef GAMEBUINO_H
    #define	GAMEBUINO_H
    
    #include <Arduino.h>
    #include <avr/pgmspace.h>
    #include <avr/sleep.h>
    #include "settings.c"
    //#include "Backlight.h" //duhjoker use setBacklight()
    #include "DisplayRGB.h"
    #include "Buttons.h"
    #include "Battery.h"
    //#include "Sound.h"
    
    #define load_game (*((void(*)(const char* filename))(0x7ffc/2)))
    #define write_flash_page (*((void(*)(const char * page, unsigned char * buffer))(0x7ffa/2)))
    
    #define wrap(i, imax) ((imax+i)%(imax))
    
    class Gamebuino {
    public:
       Backlight backlight;
       Buttons buttons;
       Battery battery;
       //Sound sound;
       Display display;
    
        void begin();
    	void titleScreen(const __FlashStringHelper* name, const uint8_t *logo);
    	void titleScreen(const __FlashStringHelper* name);
    	void titleScreen(const uint8_t* logo);
        void titleScreen();
        boolean update();
    	uint8_t startMenuTimer;
        uint32_t frameCount;
        void setFrameRate(uint8_t fps);
    	void pickRandomSeed();
    	
    	uint8_t getCpuLoad();
        uint16_t getFreeRam();
        uint16_t frameDurationMicros;
        uint32_t frameStartMicros, frameEndMicros;
        
        int8_t menu(const char* const* items, uint8_t length);
        void keyboard(char* text, uint8_t length);
        void popup(const __FlashStringHelper* text, uint8_t duration);
    	//void adjustVolume();
    	void changeGame();
    	boolean settingsAvailable();
    	void readSettings();
    	void getDefaultName(char* string);
    	
    	boolean collidePointRect(int16_t x1, int16_t y1 ,int16_t x2 ,int16_t y2, int16_t w, int16_t h);
    	boolean collideRectRect(int16_t x1, int16_t y1, int16_t w1, int16_t h1 ,int16_t x2 ,int16_t y2, int16_t w2, int16_t h2);
        boolean collideBitmapBitmap(int16_t x1, int16_t y1, const uint8_t* b1, int16_t x2, int16_t y2, const uint8_t* b2);
    
    	
    private:
        uint8_t timePerFrame;
        uint32_t nextFrameMillis;
        void updatePopup();
        const __FlashStringHelper* popupText;
        uint8_t popupTimeLeft;
        void displayBattery();
    };
    
    #endif	/* GAMEBUINO_H */
    the sketch....
    Code:
    #include <SPI.h>
    #include <DisplayRGB.h>
    #include "Buttons.h"
    #include "settings.c"
    #include "Gamebuino.h"
    
    Gamebuino gb;
    
    /*
    Teensy3.x and Arduino's
    You are using 4 wire SPI here, so:
     MOSI:  11//Teensy3.x/Arduino UNO (for MEGA/DUE refere to arduino site)
     MISO:  12//Teensy3.x/Arduino UNO (for MEGA/DUE refere to arduino site)
     SCK:   13//Teensy3.x/Arduino UNO (for MEGA/DUE refere to arduino site)
    ESP8266-----------------------------------
    Use:
    #define __CS  16  //(D0)
    #define __DC  5   //(D1)
    #define __RST 4   //(D2)
    
     SCLK:D5
     MOSI:D7
     */
    #define __CS1 	10
    #define __DC 	9
    /*
    Teensy 3.x can use: 2,6,10,15,20,21,22,23
    Arduino's 8 bit: any
    DUE: check arduino site
    If you do not use reset, tie it to +3V3
    */
    
    uint8_t errorCode = 0;
    
    //Display display = Display(__CS1, __DC);
    
    /*const byte tilemap[] PROGMEM = {15,9,
    8,8,
    2,2,2,2,2,2,2,8,8,2,2,2,2,2,2,
    2,2,2,2,2,1,4,8,8,2,2,2,2,2,2,
    2,2,2,2,4,8,8,8,8,2,2,2,2,2,2,
    2,2,2,4,8,8,8,8,8,2,2,2,2,2,2,
    2,2,4,8,8,8,8,8,8,3,2,2,2,2,2,
    8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
    2,2,8,8,8,8,8,8,8,8,8,8,8,2,2,
    2,2,8,8,8,8,8,8,8,8,8,8,8,2,2,
    2,2,2,2,2,2,2,2,2,2,2,2,2,2,2};
    
    const byte bush[] PROGMEM = {B00101100,B01010010,B10001001,B01000010,B10010001,B01001010,B00100100,B01111110,};
    const byte port_noir[] PROGMEM = {B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,B11111111,};
    const byte rock_terrain_master[] PROGMEM = {B01001101,B10100100,B10010001,B01001010,B10010000,B01100101,B10001001,B01011010,};
    const byte rock_valley_ne[] PROGMEM = {B10101010,B10010101,B01000100,B00101001,B00110010,B00001010,B00000100,B00000011,};
    const byte rock_valley_nw[] PROGMEM = {B01010101,B10101001,B00100010,B10010100,B01001100,B01010000,B00100000,B11000000,};
    const byte rock_valley_se[] PROGMEM = {B00000011,B00000100,B0011001,B00010010,B00101001,B01000110,B10110001,B10001010,};
    const byte rock_valley_sw[] PROGMEM = {B11000000,B00100000,B10011000,B01001000,B10010100,B01100010,B10001101,B01010001,};
    const byte turtle_rock[] PROGMEM = {B01101100,B10110010,B11010001,B01010101,B01010010,B10011001,B10000001,B11111110,};
    const byte void_tile[] PROGMEM = {B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,};
    const byte water_left_bottom[] PROGMEM = {B10001111,B10000000,B11110000,B10000000,B10001111,B10000000,B11110000,B11111111,};
    const byte water_left_middle[] PROGMEM = {B10001111,B10000000,B11110000,B10000000,B10001111,B10000000,B11110000,B10000000,};
    const byte water_left_top[] PROGMEM = {B11111111,B10000000,B11110000,B10001111,B10000000,B10000000,B11110000,B10000000,};
    const byte water_right_bottom[] PROGMEM = {B1110001,B00000001,B0000111,B00000001,B11110001,B00000001,B00001111,B11111111,};
    const byte water_right_middle[] PROGMEM = {B11110001,B00000001,B00001111,B00000001,B11110001,B00000001,B00001111,B00000001,};
    const byte water_right_top[] PROGMEM = {B11111111,B00000001,B00001111,B00000001,B11110001,B00000001,B00001111,B00000001,};
    const byte water_middle_bottom[] PROGMEM = {B11110000,B00000000,B00001111,B00000000,B11110000,B00000000,B00001111,B11111111,};
    const byte water_middle_middle[] PROGMEM = {B11110000,B00000000,B00001111,B00000000,B11110000,B00000000,B00001111,B00000000,};
    const byte water_middle_top[] PROGMEM = {B11111111,B00000000,B11110000,B00000000,B00001111,B00000000,B11110000,B00000000,};
    const byte steps[] PROGMEM = {B10000001,B01111110,B10000001,B01111110,B10000001,B01111110,B10000001,B01111110,};
    const byte dead_tree[] PROGMEM = {B10101001,B01010110,B01001001,B10101010,B01011010,B00111100,B00011000,B00011000,};
    const byte dungeon_left_bottom[] = {B11111111,B10001111,B01001111,B11111111,B10001111,B01001111,B11111111,B10001111,};
    const byte dungeon_left_top[] = {B00010001,B00101110,B00101010,B00101110,B01000000,B01000001,B10010010,B10001000,};
    const byte dungeon_right_bottom[] = {B11111111,B11110001,B11110010,B11111111,B11110001,B11110010,B11111111,B11110001,};
    const byte dungeon_right_top[] = {B10001000,B01110100,B01010100,B01110100,B00000010,B10000010,B01001001,B00010001,};
    const byte statue[] = {B10111010,B11000110,B01101100,B11101110,B11111110,B11111110,B01101100,B01101100,};
    
    const byte *spritesheet[] = {bush, port_noir, rock_terrain_master, rock_valley_ne, 
    rock_valley_nw, rock_valley_se, rock_valley_sw, turtle_rock, void_tile, water_left_bottom,
    water_left_middle, water_left_top, water_right_bottom, water_right_middle, water_right_top, 
    water_middle_bottom, water_middle_middle, water_middle_top, steps, dead_tree, dungeon_left_bottom,
    dungeon_left_top, dungeon_right_bottom, dungeon_right_top,statue}; 
    */
    
    const byte blank_square[] PROGMEM ={16,16,
     B00000000,B00000000,
     B00000000,B00000000,
     B00000000,B00000000,
     B00000000,B00000000,
     B00000000,B00000000,
     B00000000,B00000000,
     B00000000,B00000000,
     B00000000,B00000000,
     B00000000,B00000000,
     B00000000,B00000000,
     B00000000,B00000000,
     B00000000,B00000000,
     B00000000,B00000000,
     B00000000,B00000000,
     B00000000,B00000000,
     B00000000,B00000000,};
     
    const byte green_square[] PROGMEM ={16,16,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,};
    
    const byte blue_square[] PROGMEM ={16,16,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,};
    
    const byte red_square[] PROGMEM ={16,16,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,};
    
    const byte yellow_square[] PROGMEM ={16,16,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,
     B11111111,B11111111,};
    
    const byte tilemap1[] PROGMEM = {6,6,
    16,16,
    0,1,0,0,0,1,
    1,0,0,0,1,0,
    0,0,0,1,0,0,
    0,0,1,0,0,0,
    0,1,0,0,0,1,
    1,0,0,0,1,0};
    
    const byte tilemap2[] PROGMEM = {6,6,
    16,16,
    1,0,0,0,1,0,
    0,0,0,1,0,0,
    0,0,1,0,0,0,
    0,1,0,0,0,1,
    1,0,0,0,1,0,
    0,0,0,1,0,0};
    
    const byte tilemap3[] PROGMEM = {6,6,
    16,16,
    0,0,0,1,0,0,
    0,0,1,0,0,0,
    0,1,0,0,0,1,
    1,0,0,0,1,0,
    0,0,0,1,0,0,
    0,0,1,0,0,0};
    
    const byte tilemap4[] PROGMEM = {6,6,
    16,16,
    0,0,1,0,0,0,
    0,1,0,0,0,1,
    1,0,0,0,1,0,
    0,0,0,1,0,0,
    0,0,1,0,0,0,
    0,1,0,0,0,1};
    
    const byte *spritesheet1[] = {blank_square,green_square};
    const byte *spritesheet2[] = {blank_square,blue_square};
    const byte *spritesheet3[] = {blank_square,red_square};
    const byte *spritesheet4[] = {blank_square,yellow_square};
    
    
    int x=-50,y=50;
    
    void setup() {
    	Serial.begin(38400);
    	long unsigned debug_start = millis();
    	while (!Serial && ((millis() - debug_start) <= 5000));
    	Serial.println("serial ok, testing lib...");
      gb.begin();
      gb.titleScreen(F("test"));
      gb.display.setFrameRate(62);
      gb.display.persistence = false;
      //the following it's mainly for Teensy
      //it will help you to understand if you have choosed the
      //wrong combination of pins!
      errorCode = display.getErrorCode();
      if (errorCode != 0) {
    	  Serial.print("Init error! ");
    	  if (bitRead(errorCode, 0)) Serial.print("MOSI or SCLK pin mismach!\n");
    	  if (bitRead(errorCode, 1)) Serial.print("CS or DC pin mismach!\n");
      }
      else {
    	  Serial.println("Inited");
      }
    }
    
    void loop(void) {
    //updates the gamebuino (the display, the sound, the auto backlight... everything)
      //returns true when it's time to render a new frame (20 times/second)
      if(gb.display.update()){
      //if(buttons.repeat(BTN_L,1));//{x--;}
    
      //display.drawTilemap(x,y,tilemap1,spritesheet1, GREEN); 
      //display.drawTilemap(x,y,tilemap2,spritesheet2, BLUE); 
      //display.drawTilemap(x,y,tilemap3,spritesheet3, RED); 
      //display.drawTilemap(x,y,tilemap4,spritesheet3, YELLOW); 
      gb.display.drawBitmap1(160,110,green_square,16,16,GREEN);
    
      //if(buttons.repeat(BTN_L,1)){
      gb.display.drawBitmap1(175,125,blue_square,16,16,BLUE);
    
      gb.display.drawBitmap1(195,145,green_square,16,16,RED);
        }
    }
    attached is my library
    Attached Files Attached Files

  2. #2
    Senior Member Duhjoker's Avatar
    Join Date
    Aug 2016
    Posts
    431
    here is my display file.....

    Code:
    #ifndef _DisplayRGB_H_
    #define _DisplayRGB_H_
    
    #include "Arduino.h"
    
    #include <limits.h>
    #include "pins_arduino.h"
    #include "wiring_private.h"
    #include <stdio.h>
    #include <stdlib.h>
    #include "Print.h"
    #include <SPI.h>
    
    #include "settings.c"
    #include <Buttons.h>
    #include "Battery.h"
    #include "Backlight.h"
    
    
    #include "_includes/TFT_ILI93XX_cpuCommons.h"
    #include "_includes/TFT_ILI93XX_settings.h"
    
    //Load sumotoy universal descriptors (used in many other libraries)
    #include "_includes/sumotoy_fontDescription.h"
    #include "_includes/sumotoy_imageDescription.h"
    #include "_includes/sumotoy_iconDescription.h"
    
    ////////////////////////////////////////////////
    //////////////////////duhjoker//////////////////
    ////////////////////////////////////////////////
    
    #define BLACK       0x0000 
    #define WHITE       0xFFFF 
    #define GRAY        0x8410
    #define DARKGRAY    0xAD55 
    #define LIGHTGREY   0xD69A
    #define BLUE        0x001F 
    #define DARKBLUE    0x0011 
    #define GREEN       0x07E0
    #define DARKGREEN   0x8DF1 
    #define SANDYBROWN  0xF52C
    #define YELLOW      0xFFE0 
    #define ORANGE      0xFD20 
    #define PINK        0xFE19 
    #define RED         0xF800 
    #define PURPLE      0x8010 
    #define BROWN       0xA145
    #define BEIGE       0xF7BB
    #define CYAN    	0x07FF
    #define MAGENTA 	0xF81F
    
    
    
    
    //////////////////////////
    /////////duhjoker/////////
    //////////////////////////
    //for extended bitmap function :
    #define NOROT 0
    #define ROTCCW 1
    #define ROT180 2
    #define ROTCW 3
    #define NOFLIP 0
    #define FLIPH 1
    #define FLIPV 2
    #define FLIPVH 3
    
    //#if (DISPLAY_ROT == NO_ROT)||(DISPLAY_ROT == ROT180) //landscape mode
    //#define LCDWIDTH 340
    //#define LCDHEIGHT 220
    //#else //portrait mode
    //#define LCDWIDTH 220
    //#define LCDHEIGHT 340
    //#endif
    //#define LCDHEIGHT_NOROT 220
    //#define LCDWIDTH_NOROT 340
    
    //uint8_t _displayBuffer[1024];
    
    #if defined(_ILI93XX_DEF_FONT_PATH)
    	#include _ILI93XX_DEF_FONT_PATH
    #else
    	#include "_fonts/nullfont.c"
    #endif
    
    #if defined(ESP8266) && !defined(_ESP8266_STANDARDMODE)
    	#include <eagle_soc.h>
    #endif
    
    #if defined(SPI_HAS_TRANSACTION)
    	static SPISettings TFT_ILI93XXSPI;
    #endif
    
    #if !defined(swapVals)
    	#if defined(ESP8266)
    		#define swapVals(a, b) { int16_t t = a; a = b; b = t; }
    	#else
    		#define swapVals(a, b) { typeof(a) t = a; a = b; b = t; }
    	#endif
    #endif
    
    
    #define CENTER 				9998
    
    
    enum ILI93XX_modes { 		NORMAL=0,	PARTIAL,	IDLE,	SLEEP,	INVERT,	DISP_ON,	DISP_OFF };//0,1,2,3,4,5,6
    enum ILI93XX_iconMods { 	NONE=0,		TRANSPARENT,REPLACE,BOTH};//0,1,2,3
    enum ILI93XX_centerMode { 	NORM=0,		SCREEN,		REL_X,	REL_Y,	REL_XY};//0,1,2,3,4
    
    extern uint8_t _displayBuffer[];
    
    
    
    #ifdef __cplusplus
    
    class Display : public Print {
    
     public:
    
        #if defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
    	 Display(const uint8_t cspin,const uint8_t dcpin,const uint8_t rstpin=255,const uint8_t mosi=11,const uint8_t sclk=13);
    	#elif defined(__MKL26Z64__)
    	 Display(const uint8_t cspin,const uint8_t dcpin,const uint8_t rstpin=255,const uint8_t mosi=11,const uint8_t sclk=13);
    	#else
    	 Display(const uint8_t cspin,const uint8_t dcpin,const uint8_t rstpin=255);
    	#endif
    
    
    				//avoidSPIinit=true set everithing but not call SPI.init()(you should init SPI before!)
    	void     	begin(bool avoidSPIinit=false);
    	void		setArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
    	void		setPartialArea(uint16_t top,uint16_t bott);
    	void		changeMode(const enum ILI93XX_modes m);
    	void 		setbacklight(uint8_t val);
    	//void 		test();
    	uint8_t 	getMode(void);
    	int16_t		height(void) const;
    	int16_t 	width(void) const;
    	int16_t		cgHeight(void) const;
    	int16_t 	cgWidth(void) const;
    	void		setRotation(uint8_t r);
    	uint8_t 	getRotation(void);
    	void 		setBackground(uint16_t color);
    	void 		setForeground(uint16_t color);
    	uint16_t 	getBackground(void);
    	uint16_t 	getForeground(void);
    	void		useBacklight(const uint8_t pin);
    	void 		backlight(bool state);
    	uint8_t 	getErrorCode(void);
    
    	////////////////////////////////////////////////////////////////////////////////////////
    	//---------------------------- GEOMETRY ------------------------------------------------
    	////////////////////////////////////////////////////////////////////////////////////////
    
    	void		fillScreen(uint16_t color),
    				fillScreen(uint16_t color1,uint16_t color2),
    				clearScreen(void),//fill with color choosed in setBackground
    				drawPixel(int16_t x, int16_t y, uint16_t color),
    				drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color),
    				drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color),
    				drawLine(int16_t x0, int16_t y0,int16_t x1, int16_t y1, uint16_t color),
    				drawRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color),
    				fillRect(int16_t x, int16_t y, int16_t w, int16_t h,uint16_t color),
    				fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color1,uint16_t color2),
    				drawTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1,int16_t x2, int16_t y2, uint16_t color),
    				fillTriangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1,int16_t x2, int16_t y2, uint16_t color),
    				drawCircle(int16_t x, int16_t y, int16_t radius, uint16_t color),
    				fillCircle(int16_t x, int16_t y, int16_t radius, uint16_t color),
    				drawRoundRect(int16_t x, int16_t y, int16_t w, int16_t h,int16_t radius, uint16_t color),
    				fillRoundRect(int16_t x, int16_t y, int16_t w, int16_t h,int16_t radius, uint16_t color),
    				drawQuad(int16_t x0, int16_t y0,int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t x3, int16_t y3, uint16_t color),
    				fillQuad(int16_t x0, int16_t y0,int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t x3, int16_t y3, uint16_t color,bool triangled=true),
    				drawPolygon(int16_t x, int16_t y, uint8_t sides, int16_t diameter, float rot, uint16_t color),
    				drawMesh(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
    
    	void 		drawArc(uint16_t cx, uint16_t cy, uint16_t radius, uint16_t thickness, float start, float end, uint16_t color) {
    					if (start == 0 && end == _arcAngleMax) {
    						drawArcHelper(cx, cy, radius, thickness, 0, _arcAngleMax, color);
    					} else {
    						drawArcHelper(cx, cy, radius, thickness, start + (_arcAngleOffset / (float)360)*_arcAngleMax, end + (_arcAngleOffset / (float)360)*_arcAngleMax, color);
    					}
    				};
    
    	void 		drawEllipse(int16_t cx,int16_t cy,int16_t radiusW,int16_t radiusH,uint16_t color);
    	void 		ringMeter(int val, int minV, int maxV, uint8_t x, uint8_t y, uint8_t r=20, uint16_t colorScheme=4,uint16_t backSegColor=BLACK,int angle=150,uint8_t inc=5);
    	void 		drawLineAngle(int16_t x, int16_t y, int angle, uint8_t length, uint16_t color,int offset = -90);
    	void 		drawLineAngle(int16_t x, int16_t y, int angle, uint8_t start, uint8_t length, uint16_t color,int offset = -90);
    	
    	////////////////////////////////////////////////////////////////////////////////////////////
    	////////////////////////////////////////////////////////////////////////////////////////////
    	//------------------- BITMAPS--------------------------Duhjoker---------------------------//
    	////////////////////////////////////////////////////////////////////////////////////////////
    	////////////////////////////////////////////////////////////////////////////////////////////
    	//pushcolor
    	void drawBitmapPC1(int16_t x, int16_t y, const uint8_t *bitmap,int16_t w, int16_t h, uint16_t color);
    	void drawBitmapPC2(int16_t x, int16_t y,const uint8_t *bitmap, int16_t w, int16_t h,uint16_t color, uint16_t bg);
    
    	//adafruit_gfx 
    	void drawBitmap1(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color);
    	void drawBitmap2(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color, uint16_t bg);
    	void drawBitmap3(int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h, uint16_t color);
    	void drawBitmap4(int16_t x, int16_t y, uint8_t *bitmap, int16_t w, int16_t h, uint16_t color, uint16_t bg);
    	void drawXBitmap(int16_t x, int16_t y, const uint8_t *bitmap, int16_t w, int16_t h, uint16_t color);
    
    	//GAMEBUINO----SUMMONER123------for tilemap--Duhjoker
    	void drawBitmap(int8_t x, int8_t y, int8_t w, int8_t h, const uint8_t *bitmap, uint8_t dx, uint8_t dy, uint8_t dw, uint8_t dh, uint16_t color);
    	boolean getBitmapPixel(const uint8_t* bitmap, uint8_t x, uint8_t y);
    
    	//draw from SD  mouguino updated by Duhjoker 
    	//Draw bitmap from SD at position x0, y0
    	//void drawBitmapFromSdA(byte x, byte y, char *bitmap, uint16_t color);
    	//void drawBitmapFromSdB(byte x, byte y, char *bitmap, uint8_t dx, uint8_t dy, uint8_t dw, uint8_t dh, uint16_t color);
    	//int drawBitmapFromSd(byte x0, byte y0, char *bitmap, uint16_t color);
    
    	//void updateSlide();
    
    	//GAMEBUINO----SUMMONER123
    	void drawTilemap(int x, int y, const uint8_t *tilemap, const uint8_t **spritesheet, uint16_t color);
    	void drawTilemap(int x, int y, const uint8_t *tilemap, const uint8_t **spritesheet, uint8_t dx, uint8_t dy, uint8_t dw, uint8_t dh, uint16_t color);
    
    	//void drawTilemap1(int x, int y, const uint8_t *tilemap, const uint8_t **spritesheet, uint8_t dx, uint8_t dy, uint8_t dw, uint8_t dh, uint16_t color);
    	
    	//////////////////////////////////////////////////////////////////////////////
    	///////////////////////////////////////////////////////////////////////////////
        //-------------collision-----------------------Duhjoker------------------------
    	///////////////////////////////////////////////////////////////////////////////
    	///////////////////////////////////////////////////////////////////////////////
    	boolean collidePointRect(int16_t x1, int16_t y1, int16_t x2, int16_t y2, int16_t w, int16_t h);
    	boolean collideRectRect(int16_t x1, int16_t y1, int16_t w1, int16_t h1, int16_t x2, int16_t y2, int16_t w2, int16_t h2);
    	boolean collideBitmapBitmap(int16_t x1, int16_t y1, const uint8_t* b1, int16_t x2, int16_t y2, const uint8_t* b2);
    	
    	///////////////////////////////////////////////////////////////////////////////
    	///////////////////////////////////////////////////////////////////////////////
    	//-------------Buffer/Misc-----------------------Duhjoker--------------------//
    	///////////////////////////////////////////////////////////////////////////////
    	///////////////////////////////////////////////////////////////////////////////
    
    	boolean update();
    	uint8_t startMenuTimer;
    	uint32_t frameCount;
    	uint8_t getCpuLoad();
    	uint16_t getFreeRam();
    	uint16_t frameDurationMicros;
    	uint32_t frameStartMicros, frameEndMicros;
        
    	uint8_t* getBuffer();
    
    	int8_t cursorX, cursorY;
    	
    	boolean persistence; //disable clean() at each frame if true
    	
    	boolean settingsAvailable();
    	void readSettings();
    
    	void setFrameRate(uint8_t fps);
    	void clear(void);
    	void pickRandomSeed();
    
    	void popup(const __FlashStringHelper* text, uint8_t duration);
    
    	//void setColor(uint16_t color);
    	//void setColor(uint16_t color, bg);   //DUHJOKER COLOR LCD SPECIFIC.... USE BEFORE DRAWBITMAP AND TILEMAP FUNCTIONS
    
    	//////////////////////////////////////////////////////////////////////////////////////////
    	//----------------------------PUSH-------------------------------------------------------/	
    	//////////////////////////////////////////////////////////////////////////////////////////
    	
    	void		pushColor(uint16_t color);
    	void 		startPushData(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
    	void 		pushData(uint16_t color);
    	void 		endPushData();
    	void 		drawImage(int16_t x, int16_t y,const tPicture *img,const enum ILI93XX_iconMods m=NONE,uint16_t b=BLACK);
    	void 		drawIcon(int16_t x, int16_t y,const tIcon *icon,uint8_t scale=1,uint16_t f=WHITE,uint16_t b=BLACK,bool inverse=false);
    	//------------------------------- TEXT ----------------------------------------------------
        void		setTextColor(uint16_t color);
        void		setTextColor(uint16_t frgrnd, uint16_t bckgnd);
    	void		setTextScale(uint8_t s);
    	void 		setTextScale(uint8_t sx,uint8_t sy);
        void		setTextWrap(boolean w);
    	void		setCharSpacing(uint8_t space);
    	void 		setFontInterline(uint8_t distance);
    	void		setInternalFont(void);
    	void 		setFont(const tFont *font);
    	virtual size_t 	write(uint8_t b) { _textWrite((const char *)&b, 1); return 1;}
    	virtual size_t  write(const uint8_t *buffer, size_t size) {_textWrite((const char *)buffer, size); return size;}
    	//void		getStringBox(int16_t &w,int16_t &h);
    	//inline void swapVals(int16_t &a, int16_t &b) { int16_t t = a; a = b; b = t; }
        //------------------------------- CURSOR ----------------------------------------------------
    	void		setCursor(int16_t x,int16_t y,enum ILI93XX_centerMode c=NORM);
    	void		getCursor(int16_t &x,int16_t &y);
    	//------------------------------- SCROLL ----------------------------------------------------
    	void 		defineScrollArea(int16_t tfa, int16_t bfa);
    
    	boolean		scroll(int16_t pointer);
    	uint8_t		getScrollDirection(void);
    	void		setScrollDirection(uint8_t dir);
    	int16_t		getScrollTop(void);
    	int16_t		getScrollBottom(void);
    	#if !defined (SPI_HAS_TRANSACTION)
    	void 		setBitrate(uint32_t n);//will be deprecated
    	#endif
    	//------------------------------- COLOR ----------------------------------------------------
    	uint16_t 		gradient(uint8_t val);
    	uint16_t 		colorInterpolation(uint16_t color1,uint16_t color2,uint16_t pos,uint16_t div=100);
    	uint16_t 		colorInterpolation(uint8_t r1,uint8_t g1,uint8_t b1,uint8_t r2,uint8_t g2,uint8_t b2,uint16_t pos,uint16_t div=100);
    	inline uint16_t Color565(uint8_t r, uint8_t g, uint8_t b) {return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3);};
    	inline uint16_t Color24To565(int32_t color_) { return ((((color_ >> 16) & 0xFF) / 8) << 11) | ((((color_ >> 8) & 0xFF) / 4) << 5) | (((color_) &  0xFF) / 8);}
    	inline uint16_t htmlTo565(int32_t color_) { return (uint16_t)(((color_ & 0xF80000) >> 8) | ((color_ & 0x00FC00) >> 5) | ((color_ & 0x0000F8) >> 3));}
    	inline void 	Color565ToRGB(uint16_t color, uint8_t &r, uint8_t &g, uint8_t &b){r = (((color & 0xF800) >> 11) * 527 + 23) >> 6; g = (((color & 0x07E0) >> 5) * 259 + 33) >> 6; b = ((color & 0x001F) * 527 + 23) >> 6;}
    	//void 			printPacket(word data,uint8_t count);
    
    	typedef struct {       //line 171 "Public Variables   - ADD by Summoner123
    		int x;                    //X coordinate                 - ADD by Summoner123
    		int y;                    //Y coordinate                 - ADD by Summoner123
    		const byte *spritecol;    //Sprite of object             - ADD b Summoner123
    	}object;
    	object solid[60];         // Matriz were saved a Sprite, X and Y cordinates of all tiles on the screen - ADD by Summoner123
    
    	byte numcolision = 0;     //count of solid objects indacat how many tiles drawed on the screen - ADD by Summoner123
    
    	bool flagcollision = true;
    
     protected:
    	int16_t					_width, _height;
    	volatile int16_t		_cursorX, _cursorY;
    
    	int						_spaceCharWidth;
    	const tFont   		*	_currentFont;
    	uint8_t					_charSpacing;
    	uint16_t 				_textForeground;
    	uint16_t 				_textBackground;
    	uint8_t					_textScaleX;
    	uint8_t					_textScaleY;
    	uint8_t					_centerText;
    	uint8_t					_fontInterline;
    	boolean 				_textWrap; // If set, 'wrap' text at right edge of display
    	uint8_t					_fontRemapOffset;
    	/* fot remap offset will remap sections of char to other sections
    		0: no remap
    		1:minus to CAPITAL  if (c > 96 && c < 123) c -= 32;
    		2:CAPITAl to minus  if (c > 64 && c < 91)  c += 32;
    	*/
    
    	bool					_backlight;
    	uint8_t					_initError;
    	uint8_t					_sleep;
    	float 					_arcAngleMax;
    	int 					_arcAngleOffset;
    	uint8_t					_currentMode;
    	int16_t					_scrollTop;
    	int16_t					_scrollBottom;
    	uint8_t					_scrollDir;
    
    	uint8_t					_rotation;
    	boolean					_portrait;
    
    	uint16_t				_defaultBgColor;
    	uint16_t				_defaultFgColor;
    
    	uint8_t 				_dc,_rst;
    	uint8_t					_bklPin;
    
    /* ========================================================================
    					       Low Level SPI Routines
       ========================================================================*/
    /* ----------------- AVR (UNO,Duemilanove, etc.) ------------------------*/
    	#if defined(__AVR__)
    		volatile uint8_t 	*dataport, *clkport, *csport, *rsport;
    		uint8_t  			datapinmask, clkpinmask, cspinmask, dcpinmask;
    		uint8_t 			_cs;
    
    		void spiwrite(uint8_t c)
    		__attribute__((always_inline)) {
    			SPDR = c;//load your outgoing data into the SPI shift reg's data register
    			while(!(SPSR & _BV(SPIF)));//wait for the data to be transmitted on MOSI
    		}
    
    
    		void spiwrite16(uint16_t c)
    		__attribute__((always_inline)) {
    			spiwrite(c >> 8); spiwrite(c);
    		}
    
    		void enableCommandStream(void)
    		__attribute__((always_inline)) {
    			*rsport &= ~dcpinmask;//low
    		}
    
    		void enableDataStream(void)
    		__attribute__((always_inline)) {
    			*rsport |= dcpinmask;//hi
    		}
    
    		void startTransaction(void)
    		__attribute__((always_inline)) {
    			#if defined(SPI_HAS_TRANSACTION)
    				SPI.beginTransaction(TFT_ILI93XXSPI);
    			#endif
    				*csport &= ~cspinmask;//low
    		}
    
    		void endTransaction(void)
    		__attribute__((always_inline)) {
    			#if defined(SPI_HAS_TRANSACTION)
    				SPI.endTransaction();
    			#endif
    		}
    
    		void disableCS(void)
    		__attribute__((always_inline)) {
    			*csport |= cspinmask;//hi
    		}
    
    /* -----------------  ARM (DUE)  ------------------------*/
    	#elif defined(__SAM3X8E__)
    		Pio 				*dataport, *clkport, *csport, *rsport;
    		uint32_t  			datapinmask, clkpinmask, cspinmask, dcpinmask;
    		uint8_t 			_cs;
    
    		void spiwrite(uint8_t c)
    		__attribute__((always_inline)) {
    			SPI.transfer(c);
    		}
    
    
    		void spiwrite16(uint16_t c)
    		__attribute__((always_inline)) {
    			//SPI.transfer(c >> 8); SPI.transfer(c);
    			SPI.transfer16(c);
    		}
    
    
    		void enableCommandStream(void)
    		__attribute__((always_inline)) {
    			rsport->PIO_CODR |=  dcpinmask;//LO
    		}
    
    		void enableDataStream(void)
    		__attribute__((always_inline)) {
    			rsport->PIO_SODR |=  dcpinmask;//HI
    		}
    
    		void startTransaction(void)
    		__attribute__((always_inline)) {
    			#if defined(SPI_HAS_TRANSACTION)
    				SPI.beginTransaction(TFT_ILI93XXSPI);
    			#endif
    				csport->PIO_CODR |=  cspinmask;//LO
    		}
    
    
    		void endTransaction(void)
    		__attribute__((always_inline)) {
    			#if defined(SPI_HAS_TRANSACTION)
    				SPI.endTransaction();
    			#endif
    		}
    
    		void disableCS(void)
    		__attribute__((always_inline)) {
    			csport->PIO_SODR |=  cspinmask;//HI
    		}
    
    /* ----------------- ARM (Teensy LC) ------------------------*/
    	#elif defined(__MKL26Z64__)
    		uint8_t 			_mosi, _sclk;
    		bool				_useSPI1;
    		uint8_t 			_cs;
    		volatile uint8_t *dcportSet, *dcportClear, *csportSet, *csportClear;
    		uint8_t  cspinmask, dcpinmask;
    
    		void spiwrite(uint8_t c)
    		__attribute__((always_inline)) {
    			if (_useSPI1){
    				SPI1.transfer(c);
    			} else {
    				SPI.transfer(c);
    			}
    		}
    
    		void spiwrite16(uint16_t c)
    		__attribute__((always_inline)) {
    			if (_useSPI1){
    				SPI1.transfer16(c);
    			} else {
    				SPI.transfer16(c);
    			}
    		}
    
    		void enableCommandStream(void)
    		__attribute__((always_inline)) {
    				#if !defined(_TEENSYLC_FASTPORT)
    					digitalWriteFast(_dc,LOW);
    				#else
    					*dcportClear = dcpinmask;
    				#endif
    		}
    
    		void enableDataStream(void)
    		__attribute__((always_inline)) {
    				#if !defined(_TEENSYLC_FASTPORT)
    					digitalWriteFast(_dc,HIGH);
    				#else
    					*dcportSet = dcpinmask;
    				#endif
    		}
    
    		void startTransaction(void)
    		__attribute__((always_inline)) {
    			if (_useSPI1){
    				SPI1.beginTransaction(TFT_ILI93XXSPI);
    			} else {
    				SPI.beginTransaction(TFT_ILI93XXSPI);
    			}
    			#if !defined(_TEENSYLC_FASTPORT)
    				digitalWriteFast(_cs,LOW);
    			#else
    				*csportClear = cspinmask;
    			#endif
    		}
    
    
    		void endTransaction(void)
    		__attribute__((always_inline)) {
    			if (_useSPI1){
    				SPI1.endTransaction();
    			} else {
    				SPI.endTransaction();
    			}
    		}
    
    		void disableCS(void)
    		__attribute__((always_inline)) {
    			#if !defined(_TEENSYLC_FASTPORT)
    				digitalWriteFast(_cs,HIGH);
    			#else
    				*csportSet = cspinmask;
    			#endif
    		}
    
    /* ----------------- ARM (Teensy 3.0, Teensy 3.1, Teensy 3.2) ------------------------*/
    	#elif defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
    		uint8_t 			pcs_data, pcs_command;
    		uint8_t 			_mosi, _sclk;
    		uint8_t 			_cs;
    
    		void startTransaction(void)
    		__attribute__((always_inline)) {
    			SPI.beginTransaction(TFT_ILI93XXSPI);
    		}
    
    		void endTransaction(void)
    		__attribute__((always_inline)) {
    			SPI.endTransaction();
    		}
    
    		//Here's Paul Stoffregen magic in action...
    		void waitFifoNotFull(void) {
    			uint32_t sr;
    			uint32_t tmp __attribute__((unused));
    			do {
    				sr = KINETISK_SPI0.SR;
    				if (sr & 0xF0) tmp = KINETISK_SPI0.POPR;  // drain RX FIFO
    			} while ((sr & (15 << 12)) > (3 << 12));
    		}
    
    		void waitTransmitComplete(uint32_t mcr) __attribute__((always_inline)) {
    			uint32_t tmp __attribute__((unused));
    			while (1) {
    				uint32_t sr = KINETISK_SPI0.SR;
    				if (sr & SPI_SR_EOQF) break;  // wait for last transmit
    				if (sr &  0xF0) tmp = KINETISK_SPI0.POPR;
    			}
    			KINETISK_SPI0.SR = SPI_SR_EOQF;
    			SPI0_MCR = mcr;
    			while (KINETISK_SPI0.SR & 0xF0) {tmp = KINETISK_SPI0.POPR;}
    		}
    
    		void writecommand_cont(const uint8_t c) __attribute__((always_inline)) {
    			KINETISK_SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
    			waitFifoNotFull();
    		}
    
    		void writedata8_cont(uint8_t d) __attribute__((always_inline)) {
    			KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
    			waitFifoNotFull();
    		}
    
    		void writedata16_cont(uint16_t d) __attribute__((always_inline)) {
    			KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_CONT;
    			waitFifoNotFull();
    		}
    
    		void writecommand_last(const uint8_t c) __attribute__((always_inline)) {
    			uint32_t mcr = SPI0_MCR;
    			KINETISK_SPI0.PUSHR = c | (pcs_command << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_EOQ;
    			waitTransmitComplete(mcr);
    		}
    
    
    		void writedata8_last(uint8_t c) __attribute__((always_inline)) {
    			uint32_t mcr = SPI0_MCR;
    			KINETISK_SPI0.PUSHR = c | (pcs_data << 16) | SPI_PUSHR_CTAS(0) | SPI_PUSHR_EOQ;
    			waitTransmitComplete(mcr);
    		}
    
    		void writedata16_last(uint16_t d) __attribute__((always_inline)) {
    			uint32_t mcr = SPI0_MCR;
    			KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_EOQ;
    			waitTransmitComplete(mcr);
    		}
    
    /* ----------------- ARM (XTENSA ESP8266) ------------------------*/
    	#elif defined(ESP8266)
    		#if defined(_ESP8266_STANDARDMODE)
    			uint8_t 			_cs;
    		#else
    			uint32_t 			_cs;
    
    			uint32_t _pinRegister(uint8_t pin)
    			__attribute__((always_inline)) {
    				return _BV(pin);
    			}
    		#endif
    
    		void spiwrite(uint8_t c)
    		__attribute__((always_inline)) {
    			#if defined(_ESP8266_SPIFAST)
    				SPI.write(c);
    			#else
    				SPI.transfer(c);
    			#endif
    		}
    
    
    		void spiwrite16(uint16_t c)
    		__attribute__((always_inline)) {
    			#if defined(_ESP8266_SPIFAST)
    				SPI.write16(c);
    			#else
    				#if defined(_SPI_MULTITRANSFER)
    					//last version of ESP8266 for arduino support this
    					uint8_t pattern[2] = { (uint8_t)(c >> 8), (uint8_t)(c >> 0) };
    					SPI.writePattern(pattern, 2, (uint8_t)1);
    				#else
    					SPI.transfer(c >> 8); SPI.transfer(c >> 0);
    				#endif
    			#endif
    		}
    
    		void enableCommandStream(void)
    		__attribute__((always_inline)) {
    			#if defined(_ESP8266_STANDARDMODE)
    				digitalWrite(_dc,LOW);
    			#else
    				GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, _pinRegister(_dc));//L
    			#endif
    		}
    
    		void enableDataStream(void)
    		__attribute__((always_inline)) {
    			#if defined(_ESP8266_STANDARDMODE)
    				digitalWrite(_dc,HIGH);
    			#else
    				GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, _pinRegister(_dc));//H
    			#endif
    		}
    
    		void startTransaction(void)
    		__attribute__((always_inline)) {
    			#if defined(SPI_HAS_TRANSACTION)
    				SPI.beginTransaction(TFT_ILI93XXSPI);
    			#endif
    			#if defined(_ESP8266_STANDARDMODE)
    				digitalWrite(_cs,LOW);
    			#else
    				GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, _pinRegister(_cs));//L
    			#endif
    		}
    
    
    		void endTransaction(void)
    		__attribute__((always_inline)) {
    			#if defined(SPI_HAS_TRANSACTION)
    				SPI.endTransaction();
    			#endif
    		}
    
    		void disableCS(void)
    		__attribute__((always_inline)) {
    			#if defined(_ESP8266_STANDARDMODE)
    				digitalWrite(_cs,HIGH);
    			#else
    				GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, _pinRegister(_cs));//H
    			#endif
    		}
    
    /* ----------------- UNCKNOWN (Legacy) ------------------------*/
    	#else
    		uint8_t 			_cs;
    
    		void spiwrite(uint8_t c)
    		__attribute__((always_inline)) {
    			SPI.transfer(c);
    		}
    
    		void spiwrite16(uint16_t c)
    		__attribute__((always_inline)) {
    			SPI.transfer(c >> 8); SPI.transfer(c >> 0);
    		}
    
    		void enableCommandStream(void)
    		__attribute__((always_inline)) {
    			digitalWrite(_dc,LOW);
    		}
    
    		void enableDataStream(void)
    		__attribute__((always_inline)) {
    			digitalWrite(_dc,HIGH);
    		}
    
    		void startTransaction(void)
    		__attribute__((always_inline)) {
    			#if defined(SPI_HAS_TRANSACTION)
    				SPI.beginTransaction(TFT_ILI93XXSPI);
    			#endif
    				digitalWrite(_cs,LOW);
    		}
    
    
    		void endTransaction(void)
    		__attribute__((always_inline)) {
    			#if defined(SPI_HAS_TRANSACTION)
    				SPI.endTransaction();
    			#endif
    		}
    
    		void disableCS(void)
    		__attribute__((always_inline)) {
    			digitalWrite(_cs,HIGH);
    		}
    
    	#endif
    
     private:
    	
       /* All functions here are active only when _ILI93XX_SIZEOPTIMIZER is NOT active. */
       #if !defined(_ILI93XX_SIZEOPTIMIZER)
    /* ========================================================================
    	-------------------- Common low level commands ------------------------
    	Teensy 3.x uses different functions, This are for all the rest of MCU's
       ========================================================================*/
    		#if !defined(__MK20DX128__) && !defined(__MK20DX256__) && !defined(__MK64FX512__) && !defined(__MK66FX1M0__)
    			void writecommand_cont(const uint8_t c)
    			__attribute__((always_inline)) {
    				enableCommandStream();
    				spiwrite(c);
    			}
    
    			void writedata8_cont(uint8_t c)
    			__attribute__((always_inline)) {
    				enableDataStream();
    				spiwrite(c);
    			}
    
    			void writedata16_cont(uint16_t d)
    			__attribute__((always_inline)) {
    				enableDataStream();
    				spiwrite16(d);
    			}
    
    			void writecommand_last(const uint8_t c)
    			__attribute__((always_inline)) {
    				enableCommandStream();
    				spiwrite(c);
    				disableCS();
    			}
    
    
    			void writedata8_last(uint8_t c)
    			__attribute__((always_inline)) {
    				enableDataStream();
    				spiwrite(c);
    				disableCS();
    			}
    
    			void writedata16_last(uint16_t d)
    			__attribute__((always_inline)) {
    				enableDataStream();
    				spiwrite16(d);
    				disableCS();
    			}
    		#endif
    /* ========================================================================
    					    Fast Common Graphic Primitives
       ========================================================================*/
    
    		void drawFastHLine_cont(int16_t x, int16_t y, int16_t w, uint16_t color)
    		__attribute__((always_inline)) {
    			setAddrWindow_cont(x, y, x + w - 1, y);
    			do { writedata16_cont(color); } while (--w > 0);
    		}
    
    		void drawFastVLine_cont(int16_t x, int16_t y, int16_t h, uint16_t color)
    		__attribute__((always_inline)) {
    			setAddrWindow_cont(x, y, x, y + h - 1);
    			do { writedata16_cont(color); } while (--h > 0);
    		}
    
    		void drawPixel_cont(int16_t x, int16_t y, uint16_t color)
    		__attribute__((always_inline)) {
    			setAddrWindow_cont(x, y, x + 1, y + 1);
    			writedata16_cont(color);
    		}
    
    	#endif
    
    /* ========================================================================
    					       Helpers
       ========================================================================*/
    	void 		plot4points_cont(uint16_t cx, uint16_t cy, uint16_t x, uint16_t y, uint16_t color);
    	void		drawCircle_cont(int16_t x, int16_t y, int16_t radius, uint8_t cornername,uint16_t color);
    	void		fillCircle_cont(int16_t x, int16_t y, int16_t radius, uint8_t cornername,int16_t delta, uint16_t color);
    	void 		drawArcHelper(uint16_t cx, uint16_t cy, uint16_t radius, uint16_t thickness, float start, float end, uint16_t color);
    	void 		fillRect_cont(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color1,uint16_t color2);
    	void 		drawLine_cont(int16_t x0, int16_t y0,int16_t x1, int16_t y1, uint16_t color);
    	void 		fillTriangle_cont(int16_t x0, int16_t y0,int16_t x1, int16_t y1,int16_t x2, int16_t y2, uint16_t color);
    	void 		setArcParams(float arcAngleMax, int arcAngleOffset);
    	float 		cosDeg_helper(float angle);
    	float 		sinDeg_helper(float angle);
    	void 		clearMemory(void);
    	void 		_sendInitData(const uint8_t cmd,const uint8_t data[]);
    	bool 		boundaryCheck(int16_t x,int16_t y);
    	int16_t 	sizeCheck(int16_t origin,int16_t len,int16_t maxVal);
    	void 		setAddrWindow_cont(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
    	#if defined(_ILI93XX_SIZEOPTIMIZER)
    		#if !defined(__MK20DX128__) && !defined(__MK20DX256__) && !defined(__MK64FX512__) && !defined(__MK66FX1M0__)
    	void 		writecommand_cont(const uint8_t c);
    	void 		writedata8_cont(uint8_t c);
    	void 		writedata16_cont(uint16_t d);
    	void 		writecommand_last(const uint8_t c);
    	void 		writedata8_last(uint8_t c);
    	void 		writedata16_last(uint16_t d);
    #endif
    	
    	void 		drawFastHLine_cont(int16_t x, int16_t y, int16_t w, uint16_t color);
    	void 		drawFastVLine_cont(int16_t x, int16_t y, int16_t h, uint16_t color);
    	void 		drawPixel_cont(int16_t x, int16_t y, uint16_t color);
    	#endif
    
    	//GPO
    	int			_STRlen_helper(const char* buffer,int len);
    	int			_getCharCode(uint8_t ch);
    	void		_textWrite(const char* buffer, uint16_t len);
    	bool		_renderSingleChar(const char c);
    	void 	    _pushColors_cont(uint16_t data,uint32_t times);
    	
    	void _glyphRender_unc(const _smCharType * charGlyp, int16_t 	x, int16_t y, int charW,
    			             int charH, uint8_t scaleX, uint8_t scaleY, uint16_t totalBytes,uint8_t cspacing,
    				         uint16_t foreColor,uint16_t backColor, bool inverse);
    
    	void _charLineRender(bool lineBuffer[],	int charW, int16_t x, int16_t y, uint8_t scaleX,
    			             uint8_t scaleY, int16_t currentYposition, uint16_t foreColor);
    
    //////////////////////////////////////////
    ////////////Duhjoker//////////////////////
    //////////////////////////////////////////
    
    private:
    	uint8_t timePerFrame;
    	uint32_t nextFrameMillis;
    	void updatePopup();
    	const __FlashStringHelper* popupText;
    	uint8_t popupTimeLeft;
    	void displayBattery();
    
    };
    #endif
    
    inline uint8_t* Display::getBuffer() {
    	return _displayBuffer;
    }
    
    #endif

  3. #3
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,335
    If I am reading your stuff correctly, I believe it is because you do not have any default constructors for either the main class Gamebuino which is needed because you created an instance of it without parameters. That is with the line: Gamebuino gb;

    This could be the direct issue or could also be caused by a secondary problem. That is your GameBuino object contains a Display object and you defined it as simply: Display display
    And this class does not have a constructor that takes zero parameters. The error mentioned that the constructor for display takes 5 parameters.

    You can probably solve this several ways, like:
    Breakout the display object from your main object, and then have parameters on the constructor. and then have Pointer/Reference to the display object that you pass in to your main object.

    Or create constructors for each of these classes that does not require any information, and then have another method like init or begin or... where you pass in the information needed by each of these objects...

    Or...

    Kurt

  4. #4
    Senior Member Duhjoker's Avatar
    Join Date
    Aug 2016
    Posts
    431
    hmmmmmmmm

    ok so I decide since I had almost all of the contents gamebuino.h and gamebuino.cpp in my display file any way so why not just finish it off and merge the whole two files into my display but of course trouble ensues.


    ok so I was having trouble with the class declarations in the .cpp file so I moved them to inside the display.h instead and now the buttons and battery parts work but now I have all these display.coomand issues. like so......

    Code:
    void Display::titleScreen(const __FlashStringHelper*  name, const uint8_t *logo) {
    	if (startMenuTimer) {
    		fontSize = 1;
    		Display::_textWrap = false;
    		persistence = false;
    		battery.show = false;
    		display.setTextColor(BLACK);
    		while (1) {
    			if (update()) {
    				uint8_t logoOffset = pgm_read_byte(name) ? display.fontHeight : 0; //add an offset the logo when there is a name to display
    																				   //draw graphics
    #if LCDWIDTH == LCDWIDTH_NOROT
    				display.drawBitmap(0, 0, gamebuinoLogo);
    				if (logo) {
    					display.drawBitmap(0, 12 + logoOffset, logo);
    				}
    				display.cursorX = 0;
    				display.cursorY = 12;
    #else
    				display.drawBitmap(7, 0, gamebuinoLogo);
    				display.drawBitmap(-41, 12, gamebuinoLogo);
    				if (logo) {
    					display.drawBitmap(0, 24 + logoOffset, logo);
    				}
    				display.cursorX = 0;
    				display.cursorY = 24;
    #endif
    				display.print(name);
    
    				//A button
    				display.cursorX = TFT_ILI93XX_TFTWIDTH - display.fontWidth * 3 - 1;
    				display.cursorY = TFT_ILI93XX_TFTHEIGHT - display.fontHeight * 3 - 3;
    				if ((frameCount / 16) % 2)
    					display.println(F("\25 \20"));
    				else
    					display.println(F("\25\20 "));
    				//B button
    				display.cursorX = TFT_ILI93XX_TFTWIDTH - display.fontWidth * 3 - 1;
    				display.cursorY++;
    				//if (sound.globalVolume)
    				//	display.println(F("\26\23\24"));
    				//else
    					display.println(F("\26\23x"));
    				//C button
    				display.cursorX = TFT_ILI93XX_TFTWIDTH - display.fontWidth * 3 - 1;
    				display.cursorY++;
    				display.println(F("\27SD"));
    
    				//toggle volume when B is pressed
    				if (buttons.pressed(BTN_B)) {
    					//sound.setVolume(sound.globalVolume + 1);
    					//sound.playTick();
    				}
    				//leave the menu
    				if (buttons.pressed(BTN_A) || ((frameCount >= startMenuTimer) && (startMenuTimer != 255))) {
    					startMenuTimer = 255; //don't automatically skip the title screen next time it's displayed
    					//sound.stopPattern(0);
    					//sound.playOK();
    					break;
    				}
    				//flash the loader
    				if (buttons.pressed(BTN_T))
    					changeGame();
    			}
    		}
    		battery.show = true;
    	}
    }
    see where the display.commands are and see the battery one at the bottom. the battery works but all the ones that are display. don't.

    ok I don't know how or what to do about that. I tried moving the declaration of this which allows me to do display. in the sketch to the display.h but that doesn't work either.......

    Display display = Display(__CS1, __DC);

    some seem to let me remove the display. from in froint but some I cant get to work at all and I don't know which are which to change.

    also the library also has a sleep function using avr/sleep and I cant get that working either.

    Code:
    Arduino: 1.8.0 (Windows 7), TD: 1.34, Board: "Teensy 3.6, Serial, 180 MHz, Fast, US English"
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp: In member function 'void Display::updatePopup()':
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp:156:3: error: 'display' was not declared in this scope
    
       display.setTextColor(WHITE);
    
       ^
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp: In member function 'void Display::displayBattery()':
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp:178:3: error: 'display' was not declared in this scope
    
       display.fontSize = 1;
    
       ^
    
    In file included from C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.h:78:0,
    
                     from C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp:1:
    
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/avr/sleep.h:36:23: error: expected primary-expression before 'asm'
    
     #define sleep_cpu()  (asm("wfi"))
    
                           ^
    
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/avr/sleep.h:38:23: note: in expansion of macro 'sleep_cpu'
    
     #define sleep_mode()  sleep_cpu()
    
                           ^
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp:199:6: note: in expansion of macro 'sleep_mode'
    
          sleep_mode();
    
          ^
    
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/avr/sleep.h:36:23: error: expected ')' before 'asm'
    
     #define sleep_cpu()  (asm("wfi"))
    
                           ^
    
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/avr/sleep.h:38:23: note: in expansion of macro 'sleep_cpu'
    
     #define sleep_mode()  sleep_cpu()
    
                           ^
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp:199:6: note: in expansion of macro 'sleep_mode'
    
          sleep_mode();
    
          ^
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp: In member function 'void Display::readSettings()':
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp:234:3: error: 'display' was not declared in this scope
    
       display.contrast = pgm_read_byte(SETTINGS_PAGE+OFFSET_CONTRAST);
    
       ^
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp:251:3: error: 'display' was not declared in this scope
    
       display.contrast = SCR_CONTRAST;
    
       ^
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp: In member function 'void Display::titleScreen(const __FlashStringHelper*, const uint8_t*)':
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp:293:3: error: 'display' was not declared in this scope
    
       display.setTextColor(BLACK);
    
       ^
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp: In member function 'int8_t Display::menu(const char* const*, uint8_t)':
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp:360:20: warning: overflow in implicit constant conversion [-Woverflow]
    
      int8_t currentY = TFT_ILI93XX_TFTHEIGHT;
    
                        ^
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp:368:16: error: 'display' was not declared in this scope
    
         targetY = -display.fontHeight * length - 2; //send the menu out of the screen
    
                    ^
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp:390:43: error: 'display' was not declared in this scope
    
         targetY = -fontHeight * activeItem + (display.fontHeight + 4); //center the menu on the active item
    
                                               ^
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp:399:4: error: 'display' was not declared in this scope
    
        display.cursorY = currentY;
    
        ^
    
    In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/WProgram.h:11:0,
    
                     from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/Arduino.h:1,
    
                     from C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.h:77,
    
                     from C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp:1:
    
    C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy3/avr/pgmspace.h:88:2: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
    
     })
    
      ^
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp:407:49: note: in expansion of macro 'pgm_read_word'
    
         display.println((const __FlashStringHelper*)pgm_read_word(items + i));
    
                                                     ^
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp: In member function 'void Display::changeGame()':
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp:424:2: error: 'display' was not declared in this scope
    
      display.print(F("\35 Flashing\n  loader...\n\nDON'T TURN OFF!"));
    
      ^
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp: In member function 'void Display::begin(bool)':
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp:758:13: error: no match for call to '(Backlight) (int)'
    
      backlight(1);
    
                 ^
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp: In member function 'void Display::changeMode(ILI93XX_modes)':
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp:868:16: error: no match for call to '(Backlight) (int)'
    
         backlight(0);
    
                    ^
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp:898:44: error: no match for call to '(Backlight) (bool)'
    
       if (checkBacklight) backlight(!_backlight);
    
                                                ^
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp: In member function 'void Display::drawBitmap(int8_t, int8_t, int8_t, int8_t, const uint8_t*, uint8_t, uint8_t, uint8_t, uint8_t, uint16_t)':
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp:2577:9: warning: unused variable 'largest' [-Wunused-variable]
    
      int8_t largest = 0;
    
             ^
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp:2578:9: warning: unused variable 'largesty' [-Wunused-variable]
    
      int8_t largesty = 0;
    
             ^
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp: In member function 'void Display::drawTilemap(int, int, const uint8_t*, const uint8_t**, uint16_t)':
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp:2667:98: warning: large integer implicitly truncated to unsigned type [-Woverflow]
    
      drawTilemap(x, y, tilemap, spritesheet, 0, 0, TFT_ILI93XX_TFTWIDTH, TFT_ILI93XX_TFTHEIGHT, color);
    
                                                                                                      ^
    
    Error compiling for board Teensy 3.6.
    
    This report would have more information with
    "Show verbose output during compilation"
    option enabled in File -> Preferences.
    Attached Files Attached Files

  5. #5
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,335
    Sorry, I don't have time right now to dig in and fully understand all of this. Maybe if you could show simple example of the class setup and init stuff, it might be easier to understand and then maybe a C++ guru or the like can easily resolve the issues.

    For example before I believe you have:
    Code:
    class Gamebuino {
    public:
       Backlight backlight;
       Buttons buttons;
       Battery battery;
       //Sound sound;
       Display display;
    ...
    Which does not work because the Display class requires some parameters to be set in it's constructor.

    Again several ways to solve this is all your own code. Example create a constructor for display that takes no parameters and then maybe change or add members that allow you to set the CS and DC and/or make those members public and set them (I would avoid)...

    Or as I mentioned, make Display be it's own top object, where you pass in all of the things to it's constructor and then add a parameter to pass either a pointer or reference to it as part of the Gamebuino object. For example Radiohead library does something like this where you might create your radio object and then you pass pointer to it to a higher level protocol object...

    Another way is to have the constructor for Gamebuino take the parameters for the display and pass them to the constructor for the display...
    Again sometimes it takes me a few attempts, but maybe something like:
    public:
    Code:
    class Gamebuino {
       Backlight backlight;
       Buttons buttons;
       Battery battery;
       //Sound sound;
       Display display;
    ...
        Gamebuino (int cs, int dc);  // constructor for main object.
    Then in the cpp file you create your constructor, I think maybe something like:
    Code:
    Gamebuino::Gamebuino(int cs, int dc) : display(cs, dc)
    {
        // Any thing else you need to init... 
    }
    But I may be wrong on the : part... I know I do that for subclasses....

  6. #6
    Senior Member Duhjoker's Avatar
    Join Date
    Aug 2016
    Posts
    431
    ok what I did instead of trying to include the gamebuino .h and .cpp was to merge them into my display .h and .cpp. the reason I did so was because I had already done about half of it any way. in doing so I moved the subclass defintions to the display.h file like so.....

    Code:
    #ifndef _DisplayRGB_H_
    #define _DisplayRGB_H_
    
    #include <Arduino.h>
    #include <avr/sleep.h>
    #include <limits.h>
    #include "pins_arduino.h"
    #include "wiring_private.h"
    #include <stdio.h>
    #include <stdlib.h>
    #include "Print.h"
    #include <SPI.h>
    
    #include "settings.c"
    #include "Buttons.h"
    #include "Battery.h"
    #include "Backlight.h"
    
    extern const uint8_t font3x5[] PROGMEM;
    
    #include "_includes/TFT_ILI93XX_cpuCommons.h"
    #include "_includes/TFT_ILI93XX_settings.h"
    
    //Load sumotoy universal descriptors (used in many other libraries)
    #include "_includes/sumotoy_fontDescription.h"
    #include "_includes/sumotoy_imageDescription.h"
    #include "_includes/sumotoy_iconDescription.h"
    
    ////////////////////////////////////////////////
    //////////////////////duhjoker//////////////////
    ////////////////////////////////////////////////
    
    #define BLACK       0x0000 
    #define WHITE       0xFFFF 
    #define GRAY        0x8410
    #define DARKGRAY    0xAD55 
    #define LIGHTGREY   0xD69A
    #define BLUE        0x001F 
    #define DARKBLUE    0x0011 
    #define GREEN       0x07E0
    #define DARKGREEN   0x8DF1 
    #define SANDYBROWN  0xF52C
    #define YELLOW      0xFFE0 
    #define ORANGE      0xFD20 
    #define PINK        0xFE19 
    #define RED         0xF800 
    #define PURPLE      0x8010 
    #define BROWN       0xA145
    #define BEIGE       0xF7BB
    #define CYAN    	0x07FF
    #define MAGENTA 	0xF81F
    
    
    
    
    //////////////////////////
    /////////duhjoker/////////
    //////////////////////////
    //for extended bitmap function :
    #define NOROT 0
    #define ROTCCW 1
    #define ROT180 2
    #define ROTCW 3
    #define NOFLIP 0
    #define FLIPH 1
    #define FLIPV 2
    #define FLIPVH 3
    
    //#if (DISPLAY_ROT == NO_ROT)||(DISPLAY_ROT == ROT180) //landscape mode
    //#define LCDWIDTH 340
    //#define LCDHEIGHT 220
    //#else //portrait mode
    //#define LCDWIDTH 220
    //#define LCDHEIGHT 340
    //#endif
    //#define LCDHEIGHT_NOROT 220
    //#define LCDWIDTH_NOROT 340
    
    
    #if defined(_ILI93XX_DEF_FONT_PATH)
    	#include _ILI93XX_DEF_FONT_PATH
    #else
    	#include "_fonts/nullfont.c"
    #endif
    
    #if defined(ESP8266) && !defined(_ESP8266_STANDARDMODE)
    	#include <eagle_soc.h>
    #endif
    
    #if defined(SPI_HAS_TRANSACTION)
    	static SPISettings TFT_ILI93XXSPI;
    #endif
    
    #if !defined(swapVals)
    	#if defined(ESP8266)
    		#define swapVals(a, b) { int16_t t = a; a = b; b = t; }
    	#else
    		#define swapVals(a, b) { typeof(a) t = a; a = b; b = t; }
    	#endif
    #endif
    
    
    #define CENTER 				9998
    
    #define load_game (*((void(*)(const char* filename))(0x7ffc/2)))
    #define write_flash_page (*((void(*)(const char * page, unsigned char * buffer))(0x7ffa/2)))
    
    #define wrap(i, imax) ((imax+i)%(imax))
    
    
    enum ILI93XX_modes { 		NORMAL=0,	PARTIAL,	IDLE,	SLEEP,	INVERT,	DISP_ON,	DISP_OFF };//0,1,2,3,4,5,6
    enum ILI93XX_iconMods { 	NONE=0,		TRANSPARENT,REPLACE,BOTH};//0,1,2,3
    enum ILI93XX_centerMode { 	NORM=0,		SCREEN,		REL_X,	REL_Y,	REL_XY};//0,1,2,3,4
    
    extern uint8_t _displayBuffer[];
    
    
    
    #ifdef __cplusplus
    
    class Display : public Print {
    
     public:
    
    	 Backlight backlight;
    	 Buttons buttons;
    	 Battery battery;
    //	 Sound sound;
    //	 Display display;
    
    //	 Display display = Display(__CS1, __DC);
    
        #if defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
    	 Display(const uint8_t cspin,const uint8_t dcpin,const uint8_t rstpin=255,const uint8_t mosi=11,const uint8_t sclk=13);
    	#elif defined(__MKL26Z64__)
    	 Display(const uint8_t cspin,const uint8_t dcpin,const uint8_t rstpin=255,const uint8_t mosi=11,const uint8_t sclk=13);
    	#else
    	 Display(const uint8_t cspin,const uint8_t dcpin,const uint8_t rstpin=255);
    	#endif
    
    
    				//avoidSPIinit=true set everithing but not call SPI.init()(you should init SPI before!)
    	void     	begin(bool avoidSPIinit=false);
    	void		setArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1);
    	void		setPartialArea(uint16_t top,uint16_t bott);
    	void		changeMode(const enum ILI93XX_modes m);
    	void 		setbacklight(uint8_t val);
    	//void 		test();
    	uint8_t 	getMode(void);
    	int16_t		height(void) const;
    	int16_t 	width(void) con
    the other reason was due to some of the functions that started battery.XXXXXX I could not get to work with thw subclasses listed in the .cpp file. yea I know. any way so now I can use the button functions now listed in the .cpp file.

    but now there are functions listed in the new functions that also have display.xxxxx. now the functions listed battery.xxxxx or buttons.h works. but the commands listed in the .cpp as display.xxxxx will not work. for example...

    Code:
    void Display::updatePopup() {
    #if (ENABLE_GUI > 0)
    	if (popupTimeLeft) {
    		uint8_t yOffset = 0;
    		if (popupTimeLeft<12) {
    			yOffset = 12 - popupTimeLeft;
    		}
    		fontSize = 1;
    		display.setTextColor(WHITE);
    		fillRoundRect(0, TFT_ILI93XX_TFTHEIGHT - fontHeight + yOffset - 3, 84, display.fontHeight + 3, 3);
    		display.setTextcolor(BLACK);
    		drawRoundRect(0, TFT_ILI93XX_TFTHEIGHT - fontHeight + yOffset - 3, 84, display.fontHeight + 3, 3);
    		display.cursorX = 4;
    		display.cursorY = TFT_ILI93XX_TFTHEIGHT - display.fontHeight + yOffset - 1;
    		display.print(popupText);
    		popupTimeLeft--;
    	}
    #endif
    }
    so the ones listed as display.xxxx outside the () brackets I can simply remove the display. from the function its calling. but for the display. inside () brackets are the problem. for example look at drawroundrect() command int the function and you will see that I have removed the display. from the beginning of the command but if I remove the display. from inside the bracket in front of that command I get this error....

    change
    Code:
    fillRoundRect(0, TFT_ILI93XX_TFTHEIGHT - fontHeight + yOffset - 3, 84, fontHeight + 3, 3);
    errors...
    Code:
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp:157:91: error: no matching function for call to 'Display::fillRoundRect(int, int, int, int, int)'
    
       fillRoundRect(0, TFT_ILI93XX_TFTHEIGHT - fontHeight + yOffset - 3, 84, fontHeight + 3, 3);
    
                                                                                               ^
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp:157:91: note: candidate is:
    
    In file included from C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.cpp:1:0:
    
    C:\Users\duhjoker\Documents\Arduino\libraries\TFT_ILI93XX-master_main\DisplayRGB.h:267:5: note: void Display::fillRoundRect(int16_t, int16_t, int16_t, int16_t, int16_t, uint16_t)
    
         fillRoundRect(int16_t x, int16_t y, int16_t w, int16_t h,int16_t radius, uint16_t color),
    
         ^
    Last edited by Duhjoker; 01-30-2017 at 11:08 PM.

  7. #7
    Senior Member Duhjoker's Avatar
    Join Date
    Aug 2016
    Posts
    431

    lets look at the og Gamebuino library real quick, but come back to the last post

    ok back to the constructor stuff real quick.

    ok so in the original gamebuino library the display.h file and .cpp have these as constructors though I call them initializers since they tell the teensy to open up those pins.

    display.h
    Code:
    class Display : public Print {
    public:
    	void begin(int8_t SCLK, int8_t DIN, int8_t DC, int8_t CS, int8_t RST);
    display.cpp
    Code:
    #include "Display.h"
    
    // a 3x5 font table
    extern const uint8_t font3x5[] PROGMEM;
    
    // the memory buffer for the LCD
    uint8_t _displayBuffer[512];
    
    //the original display buffer containing the splash screen by Adafruit
    //uint8_t pcd8544_buffer[LCDWIDTH * LCDHEIGHT / 8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFC, 0xFE, 0xFF, 0xFC, 0xE0,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8,0xF8, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0x80, 0xC0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x7F,0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x1F, 0x3F, 0x7F, 0xFF, 0xFF,0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0xC7, 0xC7, 0x87, 0x8F, 0x9F, 0x9F, 0xFF, 0xFF, 0xFF,0xC1, 0xC0, 0xE0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xFC, 0xFC, 0xFC, 0xFE, 0xFE, 0xFE,0xFC, 0xFC, 0xF8, 0xF8, 0xF0, 0xE0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x80, 0xC0, 0xE0, 0xF1, 0xFB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x0F, 0x0F, 0x87,0xE7, 0xFF, 0xFF, 0xFF, 0x1F, 0x1F, 0x3F, 0xF9, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xFD, 0xFF,0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x0F, 0x07, 0x01, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,x00, 0x00, 0x00, 0xF0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE,0x7E, 0x3F, 0x3F, 0x0F, 0x1F, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0, 0xE0, 0xF1, 0xFF, 0xFF, 0xFF, 0xFF,0xFF, 0xFC, 0xF0, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01,0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x0F, 0x1F, 0x3F, 0x7F, 0x7F,0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x7F, 0x1F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
    
    void Display::begin(int8_t SCLK, int8_t DIN, int8_t DC, int8_t CS, int8_t RST) {
        din = DIN;
        sclk = SCLK;
        dc = DC;
        rst = RST;
        cs = CS;
    
        //cursorY = cursorX = 0;
        fontSize = 1;
        color = BLACK;
    	bgcolor = WHITE;
        textWrap = true;
    	setFont(font3x5);
    	//persistence = false;
    
        SPI.begin();
        SPI.setBitOrder(MSBFIRST);
        SPI.setClockDivider(SPI_CLOCK_DIV8); //can be set to 4 but some random pixels will start to appear on some displays
        SPI.setDataMode(SPI_MODE3);
        // set pin directions
        pinMode(din, OUTPUT);
        pinMode(sclk, OUTPUT);
        pinMode(dc, OUTPUT);
        if (rst > 0)
            pinMode(rst, OUTPUT);
        if (cs > 0)
            pinMode(cs, OUTPUT);
    
        // toggle RST low to reset
        if (rst > 0) {
            digitalWrite(rst, LOW);
            delay(10);
            digitalWrite(rst, HIGH);
        }
    
        clkport = portOutputRegister(digitalPinToPort(sclk));
        clkpinmask = digitalPinToBitMask(sclk);
        mosiport = portOutputRegister(digitalPinToPort(din));
        mosipinmask = digitalPinToBitMask(din);
        csport = portOutputRegister(digitalPinToPort(cs));
        cspinmask = digitalPinToBitMask(cs);
        dcport = portOutputRegister(digitalPinToPort(dc));
        dcpinmask = digitalPinToBitMask(dc);
    
        // get into the EXTENDED mode!
        command(PCD8544_FUNCTIONSET | PCD8544_EXTENDEDINSTRUCTION);
    
        // LCD bias select (4 is optimal?)
        command(PCD8544_SETBIAS | 0x4);
    
        // set VOP
        if (contrast > 0x7f)
            contrast = 0x7f;
    
        command(PCD8544_SETVOP | contrast); // Experimentally determined
    
    
        // normal mode
        command(PCD8544_FUNCTIONSET);
    
        // Set display to Normal
        command(PCD8544_DISPLAYCONTROL | PCD8544_DISPLAYNORMAL);
    
        // initial display line
        // set page address
        // set column address
        // write display data
    
        update();
    }
    now lets look at what it asking for in the gamebuino.h...
    Code:
    class Gamebuino {
    public:
        Backlight backlight;
        Buttons buttons;
        Battery battery;
        Sound sound;
        Display display;
    
        void begin();
    	void titleScreen(const __FlashStringHelper* name, const uint8_t *logo);
    	void titleScreen(const __FlashStringHelper* name);
    	void titleScreen(const uint8_t* logo);
        void titleScreen();
        boolean update();
    	uint8_t startMenuTimer;
        uint32_t frameCount;
        void setFrameRate(uint8_t fps);
    	void pickRandomSeed();
    ok so it needs a begin. here is its .cpp
    Code:
    void Gamebuino::begin() {
    	timePerFrame = 50;
    	//nextFrameMillis = 0;
    	//frameCount = 0;
    	frameEndMicros = 1;
    	startMenuTimer = 255;
    	//read default settings from flash memory (set using settings.hex)
    	readSettings();
    	//init everything
    	backlight.begin();
    	backlight.set(BACKLIGHT_MAX);
    	buttons.begin();
    	buttons.update();
    	battery.begin();
    	display.begin(SCR_CLK, SCR_DIN, SCR_DC, SCR_CS, SCR_RST);
    	sound.begin();
    	
    	//mute when B is held during start up
    	if(buttons.pressed(BTN_B)){
    		sound.setVolume(0);
    	}
    	else{ //play the startup sound on each channel for it to be louder
    		#if(NUM_CHANNELS > 0)
    			sound.playPattern(startupSound, 0);
    		#endif
    		#if(NUM_CHANNELS > 1)
    			sound.playPattern(startupSound, 1);
    		#endif
    		#if(NUM_CHANNELS > 2)
    			sound.playPattern(startupSound, 2);
    		#endif
    		#if(NUM_CHANNELS > 3)
    			sound.playPattern(startupSound, 3);
    		#endif
    	}
    }
    now look at the display.begin and its parameters. its asking for an SCR before each parameter like dcpin on the teensy. that points to the settings which look like this

    //screen
    #define SCR_CLK 13
    #define SCR_DIN 11
    #define SCR_DC A2
    #define SCR_CS A1
    #define SCR_RST A0

    but the begin in the ili93xx library goes like this....

    void begin(bool avoidSPIinit=false);

    and this

    Code:
    void TFT_ILI93XX::begin(bool avoidSPIinit) 
    {
    //initialize Vars
    	uint8_t i;
    	_currentMode = 0b00000000;
    	_backlight = 1;
    	_portrait = false;
    	_initError = 0b00000000;
    	_cursorY  = _cursorX = 0;
    	_textScaleX = _textScaleY = 1;
    	_centerText = false;
    	_scrollTop = 0;
    	_scrollBottom = 0;
    	_fontInterline = 0;
    	_charSpacing = 0;
    	_defaultBgColor = _ILI93XX_BACKGROUND;
    	_defaultFgColor = _ILI93XX_FOREGROUND;
    	_textForeground = _textBackground = _defaultFgColor;//text transparent
    	_textWrap      = true;
    	_arcAngleMax = 360;
    	_arcAngleOffset = -90;
    	_bklPin = 255;
    	//_Mactrl_Data = 0b00000000;
    	#if defined(SPI_HAS_TRANSACTION)
    		TFT_ILI93XXSPI = SPISettings(TFT_ILI93XX_SPI_SPEED, MSBFIRST, SPI_MODE0);
    	#endif
    #if defined(__AVR__)//(avr) Any 8Bit AVR
    	pinMode(_dc, OUTPUT);
    	pinMode(_cs, OUTPUT);
    	csport    = portOutputRegister(digitalPinToPort(_cs));
    	rsport    = portOutputRegister(digitalPinToPort(_dc));
    	cspinmask = digitalPinToBitMask(_cs);
    	dcpinmask = digitalPinToBitMask(_dc);
        if (!avoidSPIinit) SPI.begin();
    	#if !defined(SPI_HAS_TRANSACTION)
    		if (!avoidSPIinit){
    			SPI.setClockDivider(SPI_CLOCK_DIV2); // 8 MHz
    			SPI.setBitOrder(MSBFIRST);
    			SPI.setDataMode(SPI_MODE0);
    		}
    	#endif
    	*csport |= cspinmask;//hi
    	enableDataStream();
    so shouldn't I just need to change the parameters of the begins() in the gamebuino.h and .cpp to match my the begin in the ili93xx.cpp and .h
    Last edited by Duhjoker; 01-31-2017 at 04:52 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •