// >>>>> TINY JOYPAD TESTER GPL v3 <<<<
// >>>>> FOR TINYJOYPAD rev2 <<<<
// Programmer: Daniel C 2021
// Contact EMAIL: [email protected]
// official website: www.tinyjoypad.com
// or https://sites.google.com/view/arduino-collection
// TINY JOYPAD TESTER is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//for TINY JOYPAD rev2 (attiny85)
//the code work at 16MHZ internal
//Program the chip with an arduino uno in "Arduino as ISP" mode.
#include "TinyDriver.h"
#include "ELECTROLIB.h"
#include "TESTMODE_PIC.h"
//public var
uint8_t X_JOY,Y_JOY;
void setup() {
TinyOLED_init();
TINYJOYPAD_INIT();
}
////////////////////////////////// main ////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
void loop() {
for (uint8_t t=2;t<250;t++){
Sound(t,1);
}
X_JOY=29;
Y_JOY=30;
Tiny_Flip_JOYTESTER();
while(1){
if (TINYJOYPAD_RIGHT) {X_JOY=(X_JOY<47)?X_JOY+6:47;}else
if (TINYJOYPAD_LEFT) {X_JOY=(X_JOY>11)?X_JOY-6:11;}else{
if (X_JOY<29) {X_JOY+=6;}
if (X_JOY>29) {X_JOY-=6;}
}
if (TINYJOYPAD_DOWN) {Y_JOY=(Y_JOY<48)?Y_JOY+6:48;}else
if (TINYJOYPAD_UP) {Y_JOY=(Y_JOY>12)?Y_JOY-6:12;}else{
if (Y_JOY<30) {Y_JOY+=6;}
if (Y_JOY>30) {Y_JOY-=6;}
}
Tiny_Flip_JOYTESTER();
}}
////////////////////////////////// main end /////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
uint8_t JOYTEST_JOYTESTER(uint8_t xPASS,uint8_t yPASS){
return pgm_read_byte(&JOYTEST[xPASS+(yPASS*128)]);
}
uint8_t boutton_JOYTESTER(uint8_t xPASS,uint8_t yPASS){
if (BUTTON_DOWN) {
return (0xff-blitzSprite(97,20,xPASS,yPASS,0,boutton));
}else{
return 0xff;}
}
uint8_t Joy_JOYTESTER(uint8_t xPASS,uint8_t yPASS){
return (blitzSprite(X_JOY,Y_JOY,xPASS,yPASS,0,Joy));
}
void Tiny_Flip_JOYTESTER(void){
uint8_t y,x;
for (y = 0; y < 8; y++){
TinyOLED_Data_Start(y);
for (x = 0; x < 128; x++){
TinyOLED_Send(Joy_JOYTESTER(x,y)|(JOYTEST_JOYTESTER(x,y)&boutton_JOYTESTER(x,y)));
}
}
TinyOLED_End();
}