/**************************************************************************
This is an example for our Monochrome OLEDs based on SSD1306 drivers
Pick one up today in the adafruit shop!
------> http://www.adafruit.com/category/63_98
This example is for a 128x64 pixel display using I2C to communicate
3 pins are required to interface (two I2C and one reset).
Adafruit invests time and resources providing this open
source code, please support Adafruit and open-source
hardware by purchasing products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries,
with contributions from the open source community.
BSD license, check license.txt for more information
All text above, and the splash screen below must be
included in any redistribution.
**************************************************************************/
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#define SCREEN_WIDTH 96 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET 4 // Reset pin # (or -1 if sharing Arduino reset pin)
#define sclk 13
#define mosi 11
#define cs 10
#define rst 9
#define dc 8
#define BLACK 0x0000
#define BRED 0xF800
#define DRED 0x6000
#define RED 0xd1a6
#define GREEN 0x47e8
#define BLUE 0x473f
#define YELLOW 0xfee0
#define WHITE 0xFFFF
#define DEG2RAD 0.0174532925
// general
uint16_t r = 14;
uint16_t d = 33;
int angle = 0;
int MODE = 2; // 1 is piercer, 2 is marksman, 3 is sharpshooter
int TRIGGER = 0;
int ALT = 0;
// piercer
int piercebatt = 3;
// marksman
int markcharge = 4;
Adafruit_ILI9341 display = Adafruit_ILI9341(cs, dc);
void setup() {
// put your setup code here, to run once:
display.begin();
display.fillScreen(BLACK);
delay(500);
//piercerinit();
marksmaninit();
}
void loop() {
TRIGGER = digitalRead(7);
// put your main code here, to run repeatedly:
switch (MODE) {
case 1:
// piercer
break;
case 2:
// marksman
marksmancharge();
break;
case 3:
// sharpshooter
break;
}
}
void piercerinit() {
piercebatt = 3;
int offset = 8;
display.fillScreen(BLACK);
display.fillRoundRect(41, 8, 17, -6, 2, BLUE);
display.fillRoundRect(31, 8, 37, 55, 10, BLUE);
//display.fillRoundRect(31+(offset/2), 8+(offset/2), 37-offset, 55-offset, 10, BLACK);
display.fillRoundRect(39, 16, 21, 10, 2, BLACK);
display.fillRoundRect(39, 30, 21, 10, 2, BLACK);
display.fillRoundRect(39, 44, 21, 10, 2, BLACK);
}
void marksmaninit() {
markcharge = 4;
display.fillScreen(BLACK);
display.fillCircle(32,16, r, GREEN);
display.fillCircle(32+d,16, r, GREEN);
display.fillCircle(32,16+d, r, GREEN);
display.fillCircle(32+d,16+d, r, GREEN);
}
void marksmancharge() {
fillArc(32, 16, 10);
angle++;
}
void marksmanshoot() {
}
int fillArc(int x, int y, int time)
{
byte seg = 3; // Segments are 3 degrees wide = 120 segments for 360 degrees
float sx = r*cos((angle - 90) * DEG2RAD);
float sy = r*sin((angle - 90) * DEG2RAD);
int x1 = sx + 0.5 + x;
int y1 = sy + 0.5 + y;
float sx2 = r*cos((angle + seg - 90) * DEG2RAD);
float sy2 = r*sin((angle + seg - 90) * DEG2RAD);
int x2 = sx2 + 0.5 + x;
int y2 = sy2 + 0.5 + y;
display.fillTriangle(x,y,x1,y1,x2,y2,DRED);
delay(time);
}