[solved] update function and buttons

Understanding the language, error messages, etc.

[solved] update function and buttons

Postby Duhjoker » Tue Jan 24, 2017 11:10 pm

Ok I having couple problems with the library. First are the update functions. No problem with the buttons or back light but I'm having trouble with the gb update that is supposed to update every thing. I have to add all the buffer stuff for the update and clear functions and when I add those parts the library will compile but nothing will display.

The library comes with a clear memory function, could I just do a update for each part manually instead of calling the do all version?

Now to buttons. I added all the extra buttons to the settings file and I have buttons.h included in both my sketch and the display file. I then drew up a routine to display a green square then when I hit a button it's supposed to turn blue. But I can't get it to work.

Code: Select all
#include <SPI.h>
#include <TFT_ILI93XX.h>
#include "Buttons.h"

Buttons buttons;


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
*/

//Display display;

uint8_t errorCode = 0;

TFT_ILI93XX tft = TFT_ILI93XX(__CS1, __DC);

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,};


void setup() {
   Serial.begin(38400);
   long unsigned debug_start = millis();
   while (!Serial && ((millis() - debug_start) <= 5000));
   Serial.println("serial ok, testing lib...");
  tft.begin();

  //the following it's mainly for Teensy
  //it will help you to understand if you have choosed the
  //wrong combination of pins!
  errorCode = tft.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");
  }
}

// the loop routine runs over and over again forever
void loop(){
  //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.update()){
    //prints Hello World! on the screen
  // gb.display.drawBitmap(0,0,room_1);
 
    // gb.display.setColor(BLACK);{
    tft.drawBitmap1(70,70,green_square, 16,16,GREEN);
    //}
   
    //gb.display.setColor(GRAY);{
    //gb.display.drawBitmap(player_x,player_y,sever_front_2);
   
 
    if(buttons.repeat(BTN_L,1)){
       //gb.display.setColor(BLACK);{
    tft.drawBitmap1(70,70,blue_square,16,16 ,BLUE);
    //}
    //gb.display.setColor(GRAY);{
   // gb.display.drawBitmap(player_x,player_y,sever_rear_2);
    //}
     // player_y = player_y - 1;}
    //if(player_y <= 0){
    //  player_y = 0;}
  //}
   
  }

}
Last edited by Duhjoker on Sat Jan 28, 2017 2:43 am, edited 1 time in total.
User avatar
Duhjoker
 
Posts: 446
Joined: Sat Jul 02, 2016 4:57 am
Location: Where Palm trees grow

Re: Update function and buttons

Postby Duhjoker » Thu Jan 26, 2017 9:59 am

Ok i could use a lil help please.

I managed to get all the update function stuff like buffer and all that. I have a test sketch that puts a green square on the screen at 70 and 70. This works fine but when i add the gb.update function in the void loop, i get a black screen no bitmap and flashes black to white and back every 5 seconds. I tried adjusting the buffer size in the [] with no change, i also set the frame rate up and no change.

Could i be missing something? I want to start adding the buttons but as im testing its not working with out an update function. It just stays green.

Edit:::

Ok so started really looking the gamebuino.h and .cpp files and noticed that all it really is is some time table with the .updates from each function files like buttons and battery.

I also noted that it had an update function with on the update function to which all i could find of were two pieces from gamebuino.h's and .cpp. So i commented out that line changed clear() to clearMemory() and now i have something displaying on the screen. It was supposed to be a tilemap from my first incarnation of the zelda port but it only prints a column. As seen in the video.

Also the flashing is very visible i dont know if i need to slow the frame rate or quicken it.


https://youtu.be/Mv9ASvYkkLo
User avatar
Duhjoker
 
Posts: 446
Joined: Sat Jul 02, 2016 4:57 am
Location: Where Palm trees grow


Return to Programming Questions

Who is online

Users browsing this forum: No registered users and 23 guests

cron