dulsi / tinyscreensim

Simulator to allow you to run tinyscreen projects on your computer.
MIT License
1 stars 0 forks source link

Struggling to get the simulator to compile #1

Open flaki opened 6 years ago

flaki commented 6 years ago

Hi! I'm trying to get a a fairly simple animation to compile on the simulator but not really getting anywhere, being presented with a bunch of compiler errors.

Would you mind posting a working "test" setup and .ino file that works on your machine so I can start figuring out why this thing does not seem to work?

Find the error messages printed during execution below:

In file included from /tmp/tmp.ZAlbj4I27x/sprites.ino.cpp:5:
./TinyArcade.h: In function ‘void arcadeInit()’:
./TinyArcade.h:46:14: error: ‘INPUT_PULLUP’ was not declared in this scope
   pinMode(4, INPUT_PULLUP);
              ^~~~~~~~~~~~
./TinyArcade.h:46:3: error: ‘pinMode’ was not declared in this scope
   pinMode(4, INPUT_PULLUP);
   ^~~~~~~
./TinyArcade.h:47:8: error: ‘digitalRead’ was not declared in this scope
   if (!digitalRead(4)) {
        ^~~~~~~~~~~
./TinyArcade.h:50:15: error: ‘A0’ was not declared in this scope
   analogWrite(A0, analogRead(A0));//Set audio output to avoid picking up noise, even though audio isn't used
               ^~
./TinyArcade.h:50:15: note: suggested alternative: ‘y0’
   analogWrite(A0, analogRead(A0));//Set audio output to avoid picking up noise, even though audio isn't used
               ^~
               y0
./TinyArcade.h:50:3: error: ‘analogWrite’ was not declared in this scope
   analogWrite(A0, analogRead(A0));//Set audio output to avoid picking up noise, even though audio isn't used
   ^~~~~~~~~~~
./TinyArcade.h:50:3: note: suggested alternative: ‘analogRead’
   analogWrite(A0, analogRead(A0));//Set audio output to avoid picking up noise, even though audio isn't used
   ^~~~~~~~~~~
   analogRead
./TinyArcade.h: In function ‘uint8_t checkButton(uint8_t)’:
./TinyArcade.h:63:29: error: ‘digitalRead’ was not declared in this scope
   if ((btn & TAButton1) && !digitalRead(TinyArcadePin1))
                             ^~~~~~~~~~~
./TinyArcade.h:65:29: error: ‘digitalRead’ was not declared in this scope
   if ((btn & TAButton2) && !digitalRead(TinyArcadePin2))
                             ^~~~~~~~~~~
./TinyArcade.h: In function ‘uint8_t checkJoystick(uint8_t)’:
./TinyArcade.h:86:42: error: ‘digitalRead’ was not declared in this scope
     if ((joystickDir & TAJoystickUp) && !digitalRead(TinyArcadePinUp))
                                          ^~~~~~~~~~~
./TinyArcade.h:88:44: error: ‘digitalRead’ was not declared in this scope
     if ((joystickDir & TAJoystickDown) && !digitalRead(TinyArcadePinDown))
                                            ^~~~~~~~~~~
./TinyArcade.h:90:44: error: ‘digitalRead’ was not declared in this scope
     if ((joystickDir & TAJoystickLeft) && !digitalRead(TinyArcadePinLeft))
                                            ^~~~~~~~~~~
./TinyArcade.h:92:45: error: ‘digitalRead’ was not declared in this scope
     if ((joystickDir & TAJoystickRight) && !digitalRead(TinyArcadePinRight))
                                             ^~~~~~~~~~~
/tmp/tmp.ZAlbj4I27x/sprites.ino.cpp: In function ‘void loop()’:
/tmp/tmp.ZAlbj4I27x/sprites.ino.cpp:87:8: error: ‘tiny_arcade_nextFrame’ was not declared in this scope
   if (!tiny_arcade_nextFrame()) return;
        ^~~~~~~~~~~~~~~~~~~~~
/tmp/tmp.ZAlbj4I27x/sprites.ino.cpp:95:5: error: ‘tiny_arcade_everyXFrames’ was not declared in this scope
 if (tiny_arcade_everyXFrames( ANIMATION_DELAY )) {
     ^~~~~~~~~~~~~~~~~~~~~~~~
/tmp/tmp.ZAlbj4I27x/sprites.ino.cpp:102:1: error: ‘tiny_arcade_clear’ was not declared in this scope
 tiny_arcade_clear();
 ^~~~~~~~~~~~~~~~~
/tmp/tmp.ZAlbj4I27x/sprites.ino.cpp:104:1: error: ‘tiny_arcade_setTextSize’ was not declared in this scope
 tiny_arcade_setTextSize( 3 );
 ^~~~~~~~~~~~~~~~~~~~~~~
/tmp/tmp.ZAlbj4I27x/sprites.ino.cpp:105:1: error: ‘tiny_arcade_setCursor’ was not declared in this scope
 tiny_arcade_setCursor( 0, 0 );
 ^~~~~~~~~~~~~~~~~~~~~
/tmp/tmp.ZAlbj4I27x/sprites.ino.cpp:106:1: error: ‘tiny_arcade_print’ was not declared in this scope
 tiny_arcade_print( "Sprite\nDemo" );
 ^~~~~~~~~~~~~~~~~
/tmp/tmp.ZAlbj4I27x/sprites.ino.cpp:106:1: note: suggested alternative: ‘TinyArcadePin1’
 tiny_arcade_print( "Sprite\nDemo" );
 ^~~~~~~~~~~~~~~~~
 TinyArcadePin1
/tmp/tmp.ZAlbj4I27x/sprites.ino.cpp:108:1: error: ‘tiny_arcade_drawBitmap’ was not declared in this scope
 tiny_arcade_drawBitmap( 2 + x, 2 + y, gfx_bats + GFX_BATS_FRAMESIZE*(c_sprite), GFX_BATS_WIDTH, GFX_BATS_HEIGHT, BLACK );
 ^~~~~~~~~~~~~~~~~~~~~~
/tmp/tmp.ZAlbj4I27x/sprites.ino.cpp:113:3: error: ‘tiny_arcade_display’ was not declared in this scope
   tiny_arcade_display();
   ^~~~~~~~~~~~~~~~~~~
/tmp/tmp.ZAlbj4I27x/sprites.ino.cpp: In function ‘void tiny_arcade_clear()’:
/tmp/tmp.ZAlbj4I27x/sprites.ino.cpp:129:3: error: ‘tiny_arcade_fillScreen’ was not declared in this scope
   tiny_arcade_fillScreen(0x0000);
   ^~~~~~~~~~~~~~~~~~~~~~
/tmp/tmp.ZAlbj4I27x/sprites.ino.cpp:129:3: note: suggested alternative: ‘tiny_arcade_clear’
   tiny_arcade_fillScreen(0x0000);
   ^~~~~~~~~~~~~~~~~~~~~~
   tiny_arcade_clear
/tmp/tmp.ZAlbj4I27x/sprites.ino.cpp: In function ‘void tiny_arcade_drawBitmap(int16_t, int16_t, const uint16_t*, uint8_t, uint8_t, uint8_t)’:
/tmp/tmp.ZAlbj4I27x/sprites.ino.cpp:149:24: error: ‘min’ was not declared in this scope
   for (int y = dy; y < min(HEIGHT, dy+h); y++) {
                        ^~~
/tmp/tmp.ZAlbj4I27x/sprites.ino.cpp:149:24: note: suggested alternative: ‘sin’
   for (int y = dy; y < min(HEIGHT, dy+h); y++) {
                        ^~~
                        sin
In file included from /tmp/tmp.ZAlbj4I27x/sprites.ino.cpp:5:
./TinyArcade.h: In function ‘uint8_t checkJoystick(uint8_t)’:
./TinyArcade.h:96:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
TinyArcade.h:35:7: error: ‘uint8_t’ does not name a type
 const uint8_t TAJoystickUp  = 1 << 0;
       ^~~~~~~
TinyArcade.h:36:7: error: ‘uint8_t’ does not name a type
 const uint8_t TAJoystickDown = 1 << 1;
       ^~~~~~~
TinyArcade.h:37:7: error: ‘uint8_t’ does not name a type
 const uint8_t TAJoystickLeft  = 1 << 2;
       ^~~~~~~
TinyArcade.h:38:7: error: ‘uint8_t’ does not name a type
 const uint8_t TAJoystickRight = 1 << 3;
       ^~~~~~~
TinyArcade.h:40:7: error: ‘uint8_t’ does not name a type
 const uint8_t TAButton1  = 1 << 0;
       ^~~~~~~
TinyArcade.h:41:7: error: ‘uint8_t’ does not name a type
 const uint8_t TAButton2 = 1 << 1;
       ^~~~~~~
TinyArcade.h:43:1: error: ‘uint8_t’ does not name a type
 uint8_t arcadeVersion = 1;
 ^~~~~~~
TinyArcade.h: In function ‘void arcadeInit()’:
TinyArcade.h:46:14: error: ‘INPUT_PULLUP’ was not declared in this scope
   pinMode(4, INPUT_PULLUP);
              ^~~~~~~~~~~~
TinyArcade.h:46:3: error: ‘pinMode’ was not declared in this scope
   pinMode(4, INPUT_PULLUP);
   ^~~~~~~
TinyArcade.h:47:8: error: ‘digitalRead’ was not declared in this scope
   if (!digitalRead(4)) {
        ^~~~~~~~~~~
TinyArcade.h:48:5: error: ‘arcadeVersion’ was not declared in this scope
     arcadeVersion = 2;
     ^~~~~~~~~~~~~
TinyArcade.h:48:5: note: suggested alternative: ‘arcadeInit’
     arcadeVersion = 2;
     ^~~~~~~~~~~~~
     arcadeInit
TinyArcade.h:50:15: error: ‘A0’ was not declared in this scope
   analogWrite(A0, analogRead(A0));//Set audio output to avoid picking up noise, even though audio isn't used
               ^~
TinyArcade.h:50:19: error: ‘analogRead’ was not declared in this scope
   analogWrite(A0, analogRead(A0));//Set audio output to avoid picking up noise, even though audio isn't used
                   ^~~~~~~~~~
TinyArcade.h:50:3: error: ‘analogWrite’ was not declared in this scope
   analogWrite(A0, analogRead(A0));//Set audio output to avoid picking up noise, even though audio isn't used
   ^~~~~~~~~~~
TinyArcade.h:53:7: error: ‘arcadeVersion’ was not declared in this scope
   if (arcadeVersion == 2) {
       ^~~~~~~~~~~~~
TinyArcade.h:53:7: note: suggested alternative: ‘arcadeInit’
   if (arcadeVersion == 2) {
       ^~~~~~~~~~~~~
       arcadeInit
TinyArcade.h: At global scope:
TinyArcade.h:61:1: error: ‘uint8_t’ does not name a type
 uint8_t checkButton(uint8_t btn) {
 ^~~~~~~
TinyArcade.h:70:1: error: ‘uint8_t’ does not name a type
 uint8_t checkJoystick(uint8_t joystickDir) {
 ^~~~~~~
dulsi commented 6 years ago

First the tinyscreensim was designed to simulate the TinyVideoGame Kit not the TinyArcade. There is not much difference so it isn't hard to get TinyAracde programs working. Both colormonster and viobyte programs compile with it. They add two files in addition to TinyArcade.h. Those are TinyConfig.h and TinyGameKit.h. Instead of just including the TinyArcade.h, they do:

include "TinyConfig.h"

ifdef TINYARCADE_CONFIG

include "TinyArcade.h"

endif

ifdef TINYSCREEN_GAMEKIT_CONFIG

include "TinyGameKit.h"

endif

TinyConfig.h in the colormonster repository defaults to the TinyArcade unless it is compiled in the simulator while viobyte defaults to the TinyVideoGame Kit.

Even with that your code won't compile. When g++ line 95, it doesn't know what tiny_arcade_everyXFrames is. Proper C++ requires that the function be defined first or have a prototype. So either move them up above or add something like:

bool tiny_arcade_everyXFrames(uint8_t frames);

earlier in the program. I should probably add a simple example program to the library.

dulsi commented 6 years ago

I've added a simple example program called colortest. Let me know if you need any more help.