-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
666 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,227 @@ | ||
/* ____________________________ | ||
This software is licensed under the MIT License: | ||
https://github.com/cifertech/Daeva | ||
________________________________________ */ | ||
|
||
#include <Arduino.h> | ||
#include <U8g2lib.h> | ||
#include <Adafruit_NeoPixel.h> | ||
#include <ELECHOUSE_CC1101_SRC_DRV.h> | ||
#include <RCSwitch.h> | ||
|
||
#ifdef U8X8_HAVE_HW_I2C | ||
#include <Wire.h> | ||
#endif | ||
|
||
#include "icon.h" | ||
#include "scanner.h" | ||
#include "replay_attack.h" | ||
|
||
|
||
//U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0); // [full framebuffer, size = 1024 bytes] | ||
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); | ||
|
||
Adafruit_NeoPixel pixels(1, 16, NEO_GRB + NEO_KHZ800); | ||
|
||
RCSwitch mySwitch = RCSwitch(); | ||
|
||
|
||
const unsigned char* bitmap_icons[8] = { | ||
bitmap_icon_scanner, | ||
bitmap_icon_replay_attack, | ||
bitmap_icon_about | ||
}; | ||
|
||
|
||
const int NUM_ITEMS = 3; | ||
const int MAX_ITEM_LENGTH = 20; | ||
|
||
char menu_items [NUM_ITEMS] [MAX_ITEM_LENGTH] = { | ||
{ "Scanner" }, | ||
{ "Replay Attack" }, | ||
{ "About" } | ||
}; | ||
|
||
|
||
#define BUTTON_UP_PIN 17 | ||
#define BUTTON_SELECT_PIN 25 | ||
#define BUTTON_DOWN_PIN 27 | ||
|
||
|
||
int button_up_clicked = 0; | ||
int button_select_clicked = 0; | ||
int button_down_clicked = 0; | ||
|
||
int item_selected = 0; | ||
|
||
int item_sel_previous; | ||
int item_sel_next; | ||
|
||
int current_screen = 0; | ||
|
||
|
||
void about() { | ||
u8g2.clearBuffer(); | ||
u8g2.setFont(u8g2_font_6x10_tf); | ||
u8g2.drawStr(7, 15, "[email protected]"); | ||
u8g2.drawStr(12, 35, "GitHub/cifertech"); | ||
u8g2.drawStr(7, 55, "instagram/cifertech"); | ||
u8g2.sendBuffer(); | ||
} | ||
|
||
|
||
void setup() { | ||
|
||
u8g2.begin(); | ||
u8g2.setBitmapMode(1); | ||
|
||
pixels.begin(); | ||
|
||
pinMode(BUTTON_UP_PIN, INPUT_PULLUP); | ||
pinMode(BUTTON_SELECT_PIN, INPUT_PULLUP); | ||
pinMode(BUTTON_DOWN_PIN, INPUT_PULLUP); | ||
|
||
} | ||
|
||
|
||
void loop() { | ||
|
||
if (current_screen == 0) { // MENU SCREEN | ||
|
||
if ((digitalRead(BUTTON_UP_PIN) == LOW) && (button_up_clicked == 0)) { | ||
item_selected = item_selected - 1; | ||
button_up_clicked = 1; | ||
if (item_selected < 0) { | ||
item_selected = NUM_ITEMS-1; | ||
} | ||
} | ||
else if ((digitalRead(BUTTON_DOWN_PIN) == LOW) && (button_down_clicked == 0)) { | ||
item_selected = item_selected + 1; | ||
button_down_clicked = 1; | ||
if (item_selected >= NUM_ITEMS) { | ||
item_selected = 0; | ||
} | ||
} | ||
|
||
if ((digitalRead(BUTTON_UP_PIN) == HIGH) && (button_up_clicked == 1)) { | ||
button_up_clicked = 0; | ||
} | ||
if ((digitalRead(BUTTON_DOWN_PIN) == HIGH) && (button_down_clicked == 1)) { | ||
button_down_clicked = 0; | ||
} | ||
} | ||
|
||
|
||
bool callAbout = true; | ||
|
||
if ((digitalRead(BUTTON_SELECT_PIN) == LOW) && (button_select_clicked == 0)) { | ||
button_select_clicked = 1; | ||
|
||
if (current_screen == 0 && item_selected == 1) { | ||
rpattackSetup(); | ||
while (item_selected == 1) { | ||
if (digitalRead(BUTTON_SELECT_PIN) == HIGH) { | ||
rpattackLoop(); | ||
if (callAbout) { | ||
callAbout = false; // Toggle the state to not call about() | ||
} else { | ||
break; // Toggle the state to break the loop | ||
callAbout = true; // Reset the state for the next cycle | ||
} | ||
|
||
while (digitalRead(BUTTON_SELECT_PIN) == HIGH) { | ||
// Wait for the button to be released | ||
|
||
if (callAbout = true){ | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
if (current_screen == 0 && item_selected == 0) { | ||
scannerSetup(); | ||
while (item_selected == 0) { | ||
if (digitalRead(BUTTON_SELECT_PIN) == HIGH) { | ||
if (callAbout) { | ||
scannerLoop(); | ||
callAbout = false; // Toggle the state to not call about() | ||
} else { | ||
break; // Toggle the state to break the loop | ||
callAbout = true; // Reset the state for the next cycle | ||
} | ||
|
||
while (digitalRead(BUTTON_SELECT_PIN) == HIGH) { | ||
// Wait for the button to be released | ||
if (callAbout = true){ | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
if (current_screen == 0 && item_selected == 2) { | ||
while (item_selected == 2) { | ||
if (digitalRead(BUTTON_SELECT_PIN) == HIGH) { | ||
if (callAbout) { | ||
about(); | ||
callAbout = false; // Toggle the state to not call about() | ||
} else { | ||
break; // Toggle the state to break the loop | ||
callAbout = true; // Reset the state for the next cycle | ||
} | ||
|
||
while (digitalRead(BUTTON_SELECT_PIN) == HIGH) { | ||
// Wait for the button to be released | ||
if (callAbout = true){ | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
if ((digitalRead(BUTTON_SELECT_PIN) == HIGH) && (button_select_clicked == 1)) { | ||
button_select_clicked = 0; | ||
} | ||
|
||
|
||
item_sel_previous = item_selected - 1; | ||
if (item_sel_previous < 0) {item_sel_previous = NUM_ITEMS - 1;} | ||
item_sel_next = item_selected + 1; | ||
if (item_sel_next >= NUM_ITEMS) {item_sel_next = 0;} | ||
|
||
|
||
|
||
u8g2.clearBuffer(); | ||
|
||
if (current_screen == 0) { | ||
|
||
u8g2.drawXBMP(0, 22, 128, 21, bitmap_item_sel_outline); | ||
|
||
u8g2.setFont(u8g_font_7x14); | ||
u8g2.drawStr(25, 15, menu_items[item_sel_previous]); | ||
u8g2.drawXBMP( 4, 2, 16, 16, bitmap_icons[item_sel_previous]); | ||
|
||
u8g2.setFont(u8g_font_7x14B); | ||
u8g2.drawStr(25, 15+20+2, menu_items[item_selected]); | ||
u8g2.drawXBMP( 4, 24, 16, 16, bitmap_icons[item_selected]); | ||
|
||
u8g2.setFont(u8g_font_7x14); | ||
u8g2.drawStr(25, 15+20+20+2+2, menu_items[item_sel_next]); | ||
u8g2.drawXBMP( 4, 46, 16, 16, bitmap_icons[item_sel_next]); | ||
|
||
u8g2.drawXBMP(128-8, 0, 8, 64, bitmap_scrollbar_background); | ||
|
||
u8g2.drawBox(125, 64/NUM_ITEMS * item_selected, 3, 64/NUM_ITEMS); | ||
} | ||
|
||
u8g2.sendBuffer(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* ____________________________ | ||
This software is licensed under the MIT License: | ||
https://github.com/cifertech/Daeva | ||
________________________________________ */ | ||
|
||
// 'icon_scanner', 16x16px | ||
const unsigned char bitmap_icon_scanner [] PROGMEM = { | ||
0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x06, 0x00, 0x66, 0x00, 0x66, 0x00, 0x66, 0x00, 0x66, | ||
0x06, 0x66, 0x06, 0x66, 0x06, 0x66, 0x06, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00 | ||
}; | ||
|
||
// 'icon_replay_attack', 16x16px | ||
const unsigned char bitmap_icon_replay_attack [] PROGMEM = { | ||
0x00, 0x00, 0xC0, 0x0F, 0x00, 0x10, 0x80, 0x27, 0x00, 0x48, 0x00, 0x53, | ||
0x60, 0x54, 0xE0, 0x54, 0xE0, 0x51, 0xE0, 0x43, 0xE0, 0x03, 0x50, 0x00, | ||
0xF8, 0x00, 0x04, 0x01, 0xFE, 0x03, 0x00, 0x00, }; | ||
|
||
// 'icon_colorcube', 16x16px | ||
const unsigned char bitmap_icon_colorcube [] PROGMEM = { | ||
0x80, 0x01, 0xe0, 0x06, 0x98, 0x18, 0x86, 0x60, 0x82, 0x40, 0x82, 0x40, 0x82, 0x40, 0x82, 0x40, | ||
0x82, 0x40, 0x82, 0x40, 0x82, 0x40, 0x86, 0x60, 0x98, 0x18, 0xe0, 0x06, 0x80, 0x01, 0x00, 0x00 }; | ||
|
||
// 'icon_colorpicker', 16x16px | ||
const unsigned char bitmap_icon_colorpicker [] PROGMEM = { | ||
0x08, 0x00, 0x18, 0x00, 0x28, 0x00, 0x48, 0x00, 0x88, 0x00, 0x08, 0x01, 0x08, 0x02, 0x08, 0x04, | ||
0x08, 0x08, 0x08, 0x10, 0x08, 0x20, 0x08, 0x38, 0x88, 0x08, 0x48, 0x11, 0x28, 0x12, 0x18, 0x0c }; | ||
|
||
// 'icon_about', 16x16px | ||
const unsigned char bitmap_icon_about [] PROGMEM = { | ||
0xc0, 0x03, 0x20, 0x04, 0x10, 0x08, 0x10, 0x08, 0x20, 0x04, 0xc0, 0x03, 0x00, 0x00, 0xf8, 0x1f, | ||
0x04, 0x20, 0x02, 0x40, 0x02, 0x40, 0x12, 0x48, 0x12, 0x48, 0x12, 0x48, 0xfc, 0x3f, 0x00, 0x00 }; | ||
|
||
|
||
|
||
// 'scrollbar_background', 8x64px | ||
const unsigned char bitmap_scrollbar_background [] PROGMEM = { | ||
0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, | ||
0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, | ||
0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, | ||
0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, | ||
0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, 0x00, 0x40, | ||
0x00, 0x40, 0x00, 0x00, }; | ||
|
||
|
||
// 'item_sel_outline', 128x21px | ||
const unsigned char bitmap_item_sel_outline [] PROGMEM = { | ||
0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | ||
0xFF, 0xFF, 0xFF, 0x03, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x02, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, | ||
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x0C, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x02, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, | ||
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x0C, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x02, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, | ||
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x0C, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x02, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, | ||
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x0C, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x02, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, | ||
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x0C, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x02, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, | ||
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | ||
0x00, 0x00, 0x00, 0x0C, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, | ||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0xF8, 0xFF, 0xFF, 0xFF, | ||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x03, | ||
}; |
Oops, something went wrong.