Post by leejsmith on Oct 21, 2019 12:23:02 GMT -8
I am new to the Gameduino 3x, but have written games with normal SPI screens and use a SNES controller for input. When I read the buttons and send to the serial terminal it's instant, but the Gameduino screen does nothing for like 3-4 seconds. if you Keep pressing it will carry on showing movements, but it has this massive delay. I looked through the forum and most people are asking about the touchscreen, but could not find much about using arduino IO to control sprites so I am a bit lost as to how to fix this delay.
#include <SPI.h>
#include <GD2.h>
int DATA_CLOCK = 35;
int DATA_LATCH = 36;
int DATA_SERIAL = 37;
int counter=0;
int buttons[12];
void setup() {
// put your setup code here, to run once:
pinMode (DATA_CLOCK, OUTPUT);
digitalWrite (DATA_CLOCK, HIGH);
/** Set DATA_LATCH normally LOW **/
pinMode (DATA_LATCH, OUTPUT);
digitalWrite (DATA_LATCH, LOW);
/** Set DATA_SERIAL normally HIGH **/
pinMode (DATA_SERIAL, OUTPUT);
digitalWrite (DATA_SERIAL, HIGH);
pinMode (DATA_SERIAL, INPUT);
GD.begin();
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(DATA_LATCH, HIGH);
delayMicroseconds(12);
digitalWrite(DATA_LATCH, LOW);
delayMicroseconds(6);
/** Read data bit by bit from SR **/
for (int i = 0; i < 16; i++) {
digitalWrite (DATA_CLOCK, LOW);
delayMicroseconds (6);
if (i <= 11) {
buttons = digitalRead (DATA_SERIAL);
}
digitalWrite (DATA_CLOCK, HIGH);
delayMicroseconds (6);
}
GD.ClearColorRGB(0x103000);
GD.Clear();
//GD.cmd_text(50, 50, 31, OPT_CENTER, String(counter));
if (buttons[4]==0) {
GD.cmd_text(GD.w / 2, GD.h / 2, 31, OPT_CENTER, "u");
Serial.print(" up ");
}
if (buttons[5]==0) GD.cmd_text(GD.w / 2, GD.h / 2, 31, OPT_CENTER, "d");
if (buttons[6]==0) GD.cmd_text(GD.w / 2, GD.h / 2, 31, OPT_CENTER, "l");
if (buttons[7]==0) GD.cmd_text(GD.w / 2, GD.h / 2, 31, OPT_CENTER, "r");
GD.swap();
}
#include <EEPROM.h>#include <SPI.h>
#include <GD2.h>
int DATA_CLOCK = 35;
int DATA_LATCH = 36;
int DATA_SERIAL = 37;
int counter=0;
int buttons[12];
void setup() {
// put your setup code here, to run once:
pinMode (DATA_CLOCK, OUTPUT);
digitalWrite (DATA_CLOCK, HIGH);
/** Set DATA_LATCH normally LOW **/
pinMode (DATA_LATCH, OUTPUT);
digitalWrite (DATA_LATCH, LOW);
/** Set DATA_SERIAL normally HIGH **/
pinMode (DATA_SERIAL, OUTPUT);
digitalWrite (DATA_SERIAL, HIGH);
pinMode (DATA_SERIAL, INPUT);
GD.begin();
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(DATA_LATCH, HIGH);
delayMicroseconds(12);
digitalWrite(DATA_LATCH, LOW);
delayMicroseconds(6);
/** Read data bit by bit from SR **/
for (int i = 0; i < 16; i++) {
digitalWrite (DATA_CLOCK, LOW);
delayMicroseconds (6);
if (i <= 11) {
buttons = digitalRead (DATA_SERIAL);
}
digitalWrite (DATA_CLOCK, HIGH);
delayMicroseconds (6);
}
GD.ClearColorRGB(0x103000);
GD.Clear();
//GD.cmd_text(50, 50, 31, OPT_CENTER, String(counter));
if (buttons[4]==0) {
GD.cmd_text(GD.w / 2, GD.h / 2, 31, OPT_CENTER, "u");
Serial.print(" up ");
}
if (buttons[5]==0) GD.cmd_text(GD.w / 2, GD.h / 2, 31, OPT_CENTER, "d");
if (buttons[6]==0) GD.cmd_text(GD.w / 2, GD.h / 2, 31, OPT_CENTER, "l");
if (buttons[7]==0) GD.cmd_text(GD.w / 2, GD.h / 2, 31, OPT_CENTER, "r");
GD.swap();
}