Browse Source

Pacaman - Show depends on libraries, remove unneeded header

Did some quick edits, to try this out on my T4. beta

Decided maybe needed top header to mention this currently requires SPIN, ILI9341_t3n libraries, Also thought I would mention which pins, which I made different for T3.6 versis T4.

Also removed the ili9341_due_config.h file as nothing in it was used.

And added a message to the screen saying it was waiting for Joystick object.
main
Kurt Eckhardt 5 years ago
parent
commit
c1bc90c9b6
2 changed files with 33 additions and 67 deletions
  1. +0
    -56
      examples/Bluetooth/Pacman-Teensy-BT/ILI9341_due_config.h
  2. +33
    -11
      examples/Bluetooth/Pacman-Teensy-BT/Pacman-Teensy-BT.ino

+ 0
- 56
examples/Bluetooth/Pacman-Teensy-BT/ILI9341_due_config.h View File

@@ -1,56 +0,0 @@
/*
ILI9341_due_config.h - Arduino Due library for interfacing with ILI9341-based TFTs

Code: https://github.com/marekburiak/ILI9341_due
Documentation: http://marekburiak.github.io/ILI9341_due/

Copyright (c) 2015 Marek Buriak

*/

#ifndef _ILI9341_due_configH_
#define _ILI9341_due_configH_

// comment out the SPI mode you want to use (does not matter for AVR)
#define ILI9341_SPI_MODE_NORMAL // uses SPI library
//#define ILI9341_SPI_MODE_EXTENDED // uses Extended SPI in Due, make sure you use pin 4, 10 or 52 for CS
//#define ILI9341_SPI_MODE_DMA // uses DMA in Due

// set the clock divider
#if defined ARDUINO_SAM_DUE
#define ILI9341_SPI_CLKDIVIDER 4 // for Due
#elif defined ARDUINO_ARCH_AVR
#define ILI9341_SPI_CLKDIVIDER SPI_CLOCK_DIV2 // for Uno, Mega,...
#elif defined(TEENSYDUINO)
#define SPICLOCK 30000000
#endif



// uncomment if you want to use SPI transactions. Uncomment it if the library does not work when used with other libraries.
#define ILI_USE_SPI_TRANSACTION

// comment out if you do need to use scaled text. The text will draw then faster.
#define TEXT_SCALING_ENABLED

// default letter spacing
#define DEFAULT_LETTER_SPACING 2

// default line spacing
#define DEFAULT_LINE_SPACING 0

// sets the space between lines as part of the text
//#define LINE_SPACING_AS_PART_OF_LETTERS

// number representing the maximum angle (e.g. if 100, then if you pass in start=0 and end=50, you get a half circle)
// this can be changed with setArcParams function at runtime
#define DEFAULT_ARC_ANGLE_MAX 360

// rotational offset in degrees defining position of value 0 (-90 will put it at the top of circle)
// this can be changed with setAngleOffset function at runtime
#define DEFAULT_ANGLE_OFFSET -90




#endif

+ 33
- 11
examples/Bluetooth/Pacman-Teensy-BT/Pacman-Teensy-BT.ino View File

@@ -2,6 +2,11 @@
/* */
/* PACMAN GAME FOR ARDUINO DUE */
/* */
/* Adapted to Teensy 3.6 and 4.0 */
/* Currently requires the libraries */
/* ili9341_t3n that can be located: https://github.com/KurtE/ILI9341_t3n */
/* spin: https://github.com/KurtE/SPIN */
/* */
/******************************************************************************/
/* Copyright (c) 2014 Dr. NCX (mirracle.mxx@gmail.com) */
/* */
@@ -18,10 +23,16 @@
/******************************************************************************/
/* ILI9341: */
/*----------------------------------------------------------------------------*/
/* Teensy 3.6 Pins */
/* 8 = RST */
/* 9 = D/C */
/* 10 = CS */
/* */
/* Teensy 4.0 Beta Pins */
/* 23 = RST (Marked MCLK on T4 beta breakout) */
/* 10 = D/C (Marked CS) */
/* 9 = CS (Marked MEMCS) */
/* */
/*----------------------------------------------------------------------------*/
/* VGA: */
/*----------------------------------------------------------------------------*/
@@ -115,14 +126,23 @@ uint8_t last_bdaddr[6] = {0, 0, 0, 0, 0, 0};
// SPI Library
#include <SPI.h>

// ILI9341_due NEW lib by Marek Buriak http://marekburiak.github.io/ILI9341_due/
#include "ILI9341_due_config.h"


// Connection konfiguration of ILI9341 LCD TFT
#if defined(__MK66FX1M0__)
#define TFT_RST 8
#define TFT_DC 9
#define TFT_CS 10
#elif defined(__IMXRT1052__) || defined(__IMXRT1062__)
// On Teensy 4 beta with Paul's breakout out:
// Using pins (MOSI, MISO, SCK which are labeled on Audio board breakout location
// which are not in the Normal processor positions
// Also DC=10(CS), CS=9(BCLK) and RST 23(MCLK)
#define TFT_RST 23
#define TFT_DC 10
#define TFT_CS 9
#else
#error "This example App will only work with Teensy 3.6 or Teensy 4."
#endif
ILI9341_t3n tft = ILI9341_t3n(TFT_CS, TFT_DC, TFT_RST);
/******************************************************************************/
/* Controll KEYPAD LOOP */
@@ -373,7 +393,7 @@ const byte _opposite[] = { MStopped, MLeft, MUp, MRight, MDown };

const byte _scatterChase[] = { 7, 20, 7, 20, 5, 20, 5, 0 };
const byte _scatterTargets[] = { 2, 0, 25, 0, 0, 35, 27, 35 }; // inky/clyde scatter targets are backwards
const char _pinkyTargetOffset[] = { 4, 0, 0, 4, -4, 0, -4, 4 }; // Includes pinky target bug
const char _pinkyTargetOffset[] = { 4, 0, 0, 4, (char)-4, 0, (char)-4, 4 }; // Includes pinky target bug

#define FRIGHTENEDGHOSTSPRITE 0
#define GHOSTSPRITE 2
@@ -649,6 +669,7 @@ class Playfield
if (LEVEL % 5 == 3) return pgm_read_byte(playMap3 + ty * 28 + cx);
if (LEVEL % 5 == 4) return pgm_read_byte(playMap4 + ty * 28 + cx);
if (LEVEL % 5 == 0) return pgm_read_byte(playMap5 + ty * 28 + cx);
return 0; //
}

// Draw 1 bit BG into 8 bit tile
@@ -773,9 +794,6 @@ class Playfield

// Should be a direct Graphics call

byte n = tile[0];
byte i = 0;
word color = (word)_paletteW[n];

//------------------------------------------------------------------------------
#ifdef USE_ILI
@@ -783,6 +801,7 @@ class Playfield
#endif
//------------------------------------------------------------------------------
#ifdef USE_VGA
byte n = tile[0];
for (byte tmpY = 0; tmpY < 8; tmpY++) {

word width = 1;
@@ -960,7 +979,7 @@ class Playfield
pacman = _sprites + PACMAN;

// Chase frightened ghosts
Sprite* closestGhost = NULL;
//Sprite* closestGhost = NULL;
Sprite* frightenedGhost = NULL;
Sprite* closestAttackingGhost = NULL;
Sprite* DeadEyesStateGhost = NULL;
@@ -983,7 +1002,7 @@ class Playfield
closestAttackingGhost = s;
closestAttackingDist = d;
}
closestGhost = s;
//closestGhost = s;

if ( s->state == DeadEyesState ) DeadEyesStateGhost = s;

@@ -1576,7 +1595,6 @@ class Playfield

void Step()
{
int16_t keys = 0;

if (GAMEWIN == 1) {
LEVEL++;
@@ -1659,6 +1677,9 @@ void setup() {
tft.setRotation(2); // 180
delay(100);
tft.fillScreen(BLACK);
tft.setTextColor(ILI9341_YELLOW);
tft.setTextSize(2);
tft.println("Waiting for Joystick to connect...");
#endif
//------------------------------------------------------------------------------

@@ -1674,6 +1695,7 @@ Playfield _game;
void loop() {
if (joystick1.available()) {
if (first_joystick_message) {
tft.fillScreen(BLACK);
Serial.printf("*** First Joystick message %x:%x ***\n",
joystick1.idVendor(), joystick1.idProduct());
first_joystick_message = false;
@@ -1751,4 +1773,4 @@ void drawIndexedmap(const uint8_t *indexmap, int16_t x, int16_t y, uint16_t w, u
width++;
}
}
}
}

Loading…
Cancel
Save