Little Rook Chess on an Arduboy DevKit


(Atommann) #1

Last night I tried the “Little Rook Chess” on the Arduboy DevKit Kevin gave to me. It works!

The code is from the u8glib for Arduino, there is a ‘Chess’ folder in the example folder. Little Rook Chess

There are only 3 places need to be changed:

// setup u8g object
// software SPI mode
// SW SPI Com: SCK = 15, MOSI = 16, CS = 6, A0 = 4, RST = 12
U8GLIB_SSD1306_ADAFRUIT_128X64 u8g(15, 16, 6, 4, 12);

// keys
uint8_t uiKeyPrev = 9;
uint8_t uiKeyNext = 5;
uint8_t uiKeySelect = 8;
uint8_t uiKeyBack = 10;

  // rotate screen, if required
  //u8g.setRot180();

So I can play chess with a 8-bit AVR when I wait for the dishes in a restaurant :smile:


Little Rook Chess
Kickstarter Edition Hardware: Game status
(Kevin) #2

This is awesome! 8 bit chessmaster!


#3

Hi,

I’m a rooky here ^^ and Id like to play chess on my Arduino… can you help me for install it ?
Even in the quick start guide I cant understand all :confused:

Thanks


(Ross) #4

Setting up Little Rook for Arduboy 1.0

Install the u8glib Library

Using the Arduino Library Manager install the most current version of the u8glib library (find it by searching), then from the examples list in the file main menu, from the u8glib select the Chess example.

Modify the Source

Add or change the Chess example from the u8glib library to reflect the source below. See the comments of each code block for further instructions.

// Create the u8g object according to the Arduboy's hardware.
// SW SPI Com: SCK = 15, MOSI = 16, CS = 12, A0 = 4, RST = 6
U8GLIB_SSD1306_ADAFRUIT_128X64 u8g(15, 16, 12, 4, 6); // add this line.

// keys for Arduboy 1.0
// change the existing values
uint8_t uiKeyPrev = A2;  // left button
uint8_t uiKeyNext = A1;  // right button
uint8_t uiKeySelect = 7; // 'A' button
uint8_t uiKeyBack = 8;   // 'B' button

Modify the setup() function to stop the screen from being rotated.

void setup() {
  // rotate screen, if required
  //u8g.setRot180(); // comment this line out
  
  uiSetup();
  chess_Init(u8g.getU8g(), 0);
}

Arduboy Button Bindings

The following are the pin values for the Arduboy 1.0 buttons. These can be used to customize the button layout used by the game in the previous section.

PIN_LEFT_BUTTON = A2
PIN_RIGHT_BUTTON = A1
PIN_UP_BUTTON = A0
PIN_DOWN_BUTTON = A3
PIN_A_BUTTON = 7
PIN_B_BUTTON = 8


Sure, I can maybe try loading this up and giving instructions/porting. @Maddow, do you have a dev kit or production unit?


#5

Aaah thanks :slight_smile:
It’s a production unit


(Ross) #6

Tell me though, were you able to follow the Kickstarter guide up to the point of installing the library?
http://community.arduboy.com/t/kickstarter-quick-start-guide/725

At which step did you find yourself lost/stuck?

I should add @Maddow, it has been updated recently and now includes instructions on how to use the Library Manager in the new IDE.

So start by downloading the IDE at https://www.arduino.cc/en/Main/Software


#7

I have installed the Arduboy library on the IDE


(Ross) #8

Great! Now, if I’m not mistaken, what his suggestion is in getting the chess engine to work, for the devkit at least, is to replace the values in the Chess example in the u8glib, which can be added to the Arduino IDE.

Have a look at this wiki guide, @Maddow on u8glib, and install the library then open the Chess example from the main menu.

This game doesn’t require the Arduboy Library, but you will need the production unit’s pin values which are used to replace the devkit pin values in the code below.

uint8_t uiKeyPrev = 9;
uint8_t uiKeyNext = 5;
uint8_t uiKeySelect = 8;
uint8_t uiKeyBack = 10;

which matchs this

Will need to have these values used instead.

Which are the button values for the ARDUBOY_10 definition.

This may also help


#9

Uuuh :confused: I don’t understand…


(Ross) #10

Hrmmmm Maybe I can make a screen cap or something of the steps… A port isn’t needed. Let me see if I can do that, those are probably the “clearest” written instructions I can provide all together, but lets try small steps each post.

If you can, start by installing the the u8glib in the IDE in the same way you installed the Arduboy Library. Open the library manager and search for “u8glib”. If you get that far, let me know.

The next step would be to open an example, in particular the Chess example, in the same way you would open an Arduboy example.


#11

u8glib is now installed


(Ross) #12

Alright, now if you go to the main menu and select from the File menu, the Examples section, do you see a subsection for u8glib? If so do you see the example for Chess? If yes open it up and take a moment to skim through it. Don’t worry, it’s not super important to understand any of it really, but it’s good to gleen a few random things from it if you can. This pre-reading can help you after you go to compile it. Which is the next step.


#13

Sorry for all this time … A lot of work this week …
I look at it tomorrow!


#14

So, I readed the example for Chess


(Ross) #15

Ok, now with the source open, refer back to the original topic post, which has some information about the lines that need to be changed to make this source compile for the devkit. For the lines below I’ve replaced it with the button values for the Arduboy 1.0.

Setting up Little Rook for Arduboy 1.0

Add or change the Chess example from the u8glib library to reflect the source below. See the comments of each code block for further instructions.

// Create the u8g object according to the Arduboy's hardware.
// SW SPI Com: SCK = 15, MOSI = 16, CS = 12, A0 = 4, RST = 6
U8GLIB_SSD1306_ADAFRUIT_128X64 u8g(15, 16, 12, 4, 6); // add this line.

// keys for Arduboy 1.0
// change the existing values
uint8_t uiKeyPrev = A2;  // left button
uint8_t uiKeyNext = A1;  // right button
uint8_t uiKeySelect = 7; // 'A' button
uint8_t uiKeyBack = 8;   // 'B' button

Modify the setup() function to stop the screen from being rotated.

void setup() {
  // rotate screen, if required
  //u8g.setRot180(); // comment this line out
  
  uiSetup();
  chess_Init(u8g.getU8g(), 0);
}

Arduboy Button Bindings

The following are the pin values for the Arduboy 1.0 buttons. These can be used to customize the button layout used by the game in the previous section.

PIN_LEFT_BUTTON = A2
PIN_RIGHT_BUTTON = A1
PIN_UP_BUTTON = A0
PIN_DOWN_BUTTON = A3
PIN_A_BUTTON = 7
PIN_B_BUTTON = 8


#17

I think it’s done, I changed the source


(Ross) #18

Ok now select your target board as the leonardo, and then select the COM port your Arduboy is on. After setting up the device, you then will hit compile and upload, and you should be ready to play.

If it compiles with errors, please post them back in here and we can resolve them.


#19

Im in COM1 not COM3 like the tutorial :confused:

How I compile and Upload ?


(Ross) #20

Here is a pretty helpful thread as well,
http://community.arduboy.com/t/getting-started-with-the-arduboy-dev-kit-page-facing-up/223

When selecting a COM port, as long as it shows up as a leonardo you should be fine. Windows will tend to place it on COM3 in most cases. When in doubt, save your work, and restart the IDE with the unit plugged in. You can also open up the Windows Device Manager and check which COM it is on.

Anyway, here’s the part that is important to you from the thead above, it should help with the compile/build and upload process.

Select the Leonardo Board and a COM port

  • From the Arduino IDE menu select Tools > Board > Arduino Leonardo.

  • Select the appropriate COM from Tools > Com.

Uploading

In the upper left corner of the Arduino IDE are two buttons used to verify (compile) and upload code to the Arduboy.

To upload a game:

  • Verify the sketch.

  • Upload the sketch.

You are now ready to play!


#21

Its still COM1

Error message : u8g not declared in this scope

D:\Tytin\Mes documents\Arduino\Chess\Chess.ino: In function ‘void setup()’:

Chess:198: error: ‘u8g’ was not declared in this scope

u8g.setRot180();

^

D:\Tytin\Mes documents\Arduino\Chess\Chess.ino: In function ‘void loop()’:

Chess:207: error: ‘u8g’ was not declared in this scope

u8g.firstPage();

^

exit status 1
’u8g’ was not declared in this scope