mirror of
https://github.com/k3ng/k3ng_rotator_controller.git
synced 2025-03-13 15:46:26 +00:00
Merge f50e98c9cbd11d680a9f162db6008b4916bc6856 into 3788ad5f6ef5f3b035c304bbec40a3f8782bb3d9
This commit is contained in:
commit
a8c1fec0ec
10316
Schematic_RotorePico_2023-07-16.pdf
Normal file
10316
Schematic_RotorePico_2023-07-16.pdf
Normal file
File diff suppressed because it is too large
Load Diff
1174
k3ng_rotator_controller/Adafruit_SSD1306.cpp
Normal file
1174
k3ng_rotator_controller/Adafruit_SSD1306.cpp
Normal file
File diff suppressed because it is too large
Load Diff
206
k3ng_rotator_controller/Adafruit_SSD1306.h
Normal file
206
k3ng_rotator_controller/Adafruit_SSD1306.h
Normal file
@ -0,0 +1,206 @@
|
||||
/*!
|
||||
* @file Adafruit_SSD1306.h
|
||||
*
|
||||
* This is part of for Adafruit's SSD1306 library for monochrome
|
||||
* OLED displays: http://www.adafruit.com/category/63_98
|
||||
*
|
||||
* These displays use I2C or SPI to communicate. I2C requires 2 pins
|
||||
* (SCL+SDA) and optionally a RESET pin. SPI requires 4 pins (MOSI, SCK,
|
||||
* select, data/command) and optionally a reset pin. Hardware SPI or
|
||||
* 'bitbang' software SPI are both supported.
|
||||
*
|
||||
* 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, all text above, and the splash screen header file,
|
||||
* must be included in any redistribution.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _Adafruit_SSD1306_H_
|
||||
#define _Adafruit_SSD1306_H_
|
||||
|
||||
// ONE of the following three lines must be #defined:
|
||||
//#define SSD1306_128_64 ///< DEPRECTAED: old way to specify 128x64 screen
|
||||
#define SSD1306_128_32 ///< DEPRECATED: old way to specify 128x32 screen
|
||||
//#define SSD1306_96_16 ///< DEPRECATED: old way to specify 96x16 screen
|
||||
// This establishes the screen dimensions in old Adafruit_SSD1306 sketches
|
||||
// (NEW CODE SHOULD IGNORE THIS, USE THE CONSTRUCTORS THAT ACCEPT WIDTH
|
||||
// AND HEIGHT ARGUMENTS).
|
||||
|
||||
// Uncomment to disable Adafruit splash logo
|
||||
//#define SSD1306_NO_SPLASH
|
||||
|
||||
#if defined(ARDUINO_STM32_FEATHER)
|
||||
typedef class HardwareSPI SPIClass;
|
||||
#endif
|
||||
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <SPI.h>
|
||||
#include <Wire.h>
|
||||
|
||||
#if defined(__AVR__)
|
||||
typedef volatile uint8_t PortReg;
|
||||
typedef uint8_t PortMask;
|
||||
#define HAVE_PORTREG
|
||||
#elif defined(__SAM3X8E__)
|
||||
typedef volatile RwReg PortReg;
|
||||
typedef uint32_t PortMask;
|
||||
#define HAVE_PORTREG
|
||||
#elif (defined(__arm__) || defined(ARDUINO_FEATHER52)) && \
|
||||
!defined(ARDUINO_ARCH_MBED) && !defined(ARDUINO_ARCH_RP2040)
|
||||
typedef volatile uint32_t PortReg;
|
||||
typedef uint32_t PortMask;
|
||||
#define HAVE_PORTREG
|
||||
#endif
|
||||
|
||||
/// The following "raw" color names are kept for backwards client compatability
|
||||
/// They can be disabled by predefining this macro before including the Adafruit
|
||||
/// header client code will then need to be modified to use the scoped enum
|
||||
/// values directly
|
||||
#ifndef NO_ADAFRUIT_SSD1306_COLOR_COMPATIBILITY
|
||||
#define BLACK SSD1306_BLACK ///< Draw 'off' pixels
|
||||
#define WHITE SSD1306_WHITE ///< Draw 'on' pixels
|
||||
#define INVERSE SSD1306_INVERSE ///< Invert pixels
|
||||
#endif
|
||||
/// fit into the SSD1306_ naming scheme
|
||||
#define SSD1306_BLACK 0 ///< Draw 'off' pixels
|
||||
#define SSD1306_WHITE 1 ///< Draw 'on' pixels
|
||||
#define SSD1306_INVERSE 2 ///< Invert pixels
|
||||
|
||||
#define SSD1306_MEMORYMODE 0x20 ///< See datasheet
|
||||
#define SSD1306_COLUMNADDR 0x21 ///< See datasheet
|
||||
#define SSD1306_PAGEADDR 0x22 ///< See datasheet
|
||||
#define SSD1306_SETCONTRAST 0x81 ///< See datasheet
|
||||
#define SSD1306_CHARGEPUMP 0x8D ///< See datasheet
|
||||
#define SSD1306_SEGREMAP 0xA0 ///< See datasheet
|
||||
#define SSD1306_DISPLAYALLON_RESUME 0xA4 ///< See datasheet
|
||||
#define SSD1306_DISPLAYALLON 0xA5 ///< Not currently used
|
||||
#define SSD1306_NORMALDISPLAY 0xA6 ///< See datasheet
|
||||
#define SSD1306_INVERTDISPLAY 0xA7 ///< See datasheet
|
||||
#define SSD1306_SETMULTIPLEX 0xA8 ///< See datasheet
|
||||
#define SSD1306_DISPLAYOFF 0xAE ///< See datasheet
|
||||
#define SSD1306_DISPLAYON 0xAF ///< See datasheet
|
||||
#define SSD1306_COMSCANINC 0xC0 ///< Not currently used
|
||||
#define SSD1306_COMSCANDEC 0xC8 ///< See datasheet
|
||||
#define SSD1306_SETDISPLAYOFFSET 0xD3 ///< See datasheet
|
||||
#define SSD1306_SETDISPLAYCLOCKDIV 0xD5 ///< See datasheet
|
||||
#define SSD1306_SETPRECHARGE 0xD9 ///< See datasheet
|
||||
#define SSD1306_SETCOMPINS 0xDA ///< See datasheet
|
||||
#define SSD1306_SETVCOMDETECT 0xDB ///< See datasheet
|
||||
|
||||
#define SSD1306_SETLOWCOLUMN 0x00 ///< Not currently used
|
||||
#define SSD1306_SETHIGHCOLUMN 0x10 ///< Not currently used
|
||||
#define SSD1306_SETSTARTLINE 0x40 ///< See datasheet
|
||||
|
||||
#define SSD1306_EXTERNALVCC 0x01 ///< External display voltage source
|
||||
#define SSD1306_SWITCHCAPVCC 0x02 ///< Gen. display voltage from 3.3V
|
||||
|
||||
#define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26 ///< Init rt scroll
|
||||
#define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27 ///< Init left scroll
|
||||
#define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29 ///< Init diag scroll
|
||||
#define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A ///< Init diag scroll
|
||||
#define SSD1306_DEACTIVATE_SCROLL 0x2E ///< Stop scroll
|
||||
#define SSD1306_ACTIVATE_SCROLL 0x2F ///< Start scroll
|
||||
#define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3 ///< Set scroll range
|
||||
|
||||
// Deprecated size stuff for backwards compatibility with old sketches
|
||||
#if defined SSD1306_128_64
|
||||
#define SSD1306_LCDWIDTH 128 ///< DEPRECATED: width w/SSD1306_128_64 defined
|
||||
#define SSD1306_LCDHEIGHT 64 ///< DEPRECATED: height w/SSD1306_128_64 defined
|
||||
#endif
|
||||
#if defined SSD1306_128_32
|
||||
#define SSD1306_LCDWIDTH 128 ///< DEPRECATED: width w/SSD1306_128_32 defined
|
||||
#define SSD1306_LCDHEIGHT 32 ///< DEPRECATED: height w/SSD1306_128_32 defined
|
||||
#endif
|
||||
#if defined SSD1306_96_16
|
||||
#define SSD1306_LCDWIDTH 96 ///< DEPRECATED: width w/SSD1306_96_16 defined
|
||||
#define SSD1306_LCDHEIGHT 16 ///< DEPRECATED: height w/SSD1306_96_16 defined
|
||||
#endif
|
||||
|
||||
/*!
|
||||
@brief Class that stores state and functions for interacting with
|
||||
SSD1306 OLED displays.
|
||||
*/
|
||||
class Adafruit_SSD1306 : public Adafruit_GFX {
|
||||
public:
|
||||
// NEW CONSTRUCTORS -- recommended for new projects
|
||||
Adafruit_SSD1306(uint8_t w, uint8_t h, TwoWire *twi = &Wire,
|
||||
int8_t rst_pin = -1, uint32_t clkDuring = 400000UL,
|
||||
uint32_t clkAfter = 100000UL);
|
||||
Adafruit_SSD1306(uint8_t w, uint8_t h, int8_t mosi_pin, int8_t sclk_pin,
|
||||
int8_t dc_pin, int8_t rst_pin, int8_t cs_pin);
|
||||
Adafruit_SSD1306(uint8_t w, uint8_t h, SPIClass *spi, int8_t dc_pin,
|
||||
int8_t rst_pin, int8_t cs_pin, uint32_t bitrate = 8000000UL);
|
||||
|
||||
// DEPRECATED CONSTRUCTORS - for back compatibility, avoid in new projects
|
||||
Adafruit_SSD1306(int8_t mosi_pin, int8_t sclk_pin, int8_t dc_pin,
|
||||
int8_t rst_pin, int8_t cs_pin);
|
||||
Adafruit_SSD1306(int8_t dc_pin, int8_t rst_pin, int8_t cs_pin);
|
||||
Adafruit_SSD1306(int8_t rst_pin = -1);
|
||||
|
||||
~Adafruit_SSD1306(void);
|
||||
|
||||
bool begin(uint8_t switchvcc = SSD1306_SWITCHCAPVCC, uint8_t i2caddr = 0,
|
||||
bool reset = true, bool periphBegin = true);
|
||||
void display(void);
|
||||
void clearDisplay(void);
|
||||
void invertDisplay(bool i);
|
||||
void dim(bool dim);
|
||||
void drawPixel(int16_t x, int16_t y, uint16_t color);
|
||||
virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color);
|
||||
virtual void drawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color);
|
||||
void startscrollright(uint8_t start, uint8_t stop);
|
||||
void startscrollleft(uint8_t start, uint8_t stop);
|
||||
void startscrolldiagright(uint8_t start, uint8_t stop);
|
||||
void startscrolldiagleft(uint8_t start, uint8_t stop);
|
||||
void stopscroll(void);
|
||||
void ssd1306_command(uint8_t c);
|
||||
bool getPixel(int16_t x, int16_t y);
|
||||
uint8_t *getBuffer(void);
|
||||
|
||||
protected:
|
||||
inline void SPIwrite(uint8_t d) __attribute__((always_inline));
|
||||
void drawFastHLineInternal(int16_t x, int16_t y, int16_t w, uint16_t color);
|
||||
void drawFastVLineInternal(int16_t x, int16_t y, int16_t h, uint16_t color);
|
||||
void ssd1306_command1(uint8_t c);
|
||||
void ssd1306_commandList(const uint8_t *c, uint8_t n);
|
||||
|
||||
SPIClass *spi; ///< Initialized during construction when using SPI. See
|
||||
///< SPI.cpp, SPI.h
|
||||
TwoWire *wire; ///< Initialized during construction when using I2C. See
|
||||
///< Wire.cpp, Wire.h
|
||||
uint8_t *buffer; ///< Buffer data used for display buffer. Allocated when
|
||||
///< begin method is called.
|
||||
int8_t i2caddr; ///< I2C address initialized when begin method is called.
|
||||
int8_t vccstate; ///< VCC selection, set by begin method.
|
||||
int8_t page_end; ///< not used
|
||||
int8_t mosiPin; ///< (Master Out Slave In) set when using SPI set during
|
||||
///< construction.
|
||||
int8_t clkPin; ///< (Clock Pin) set when using SPI set during construction.
|
||||
int8_t dcPin; ///< (Data Pin) set when using SPI set during construction.
|
||||
int8_t
|
||||
csPin; ///< (Chip Select Pin) set when using SPI set during construction.
|
||||
int8_t rstPin; ///< Display reset pin assignment. Set during construction.
|
||||
|
||||
#ifdef HAVE_PORTREG
|
||||
PortReg *mosiPort, *clkPort, *dcPort, *csPort;
|
||||
PortMask mosiPinMask, clkPinMask, dcPinMask, csPinMask;
|
||||
#endif
|
||||
#if ARDUINO >= 157
|
||||
uint32_t wireClk; ///< Wire speed for SSD1306 transfers
|
||||
uint32_t restoreClk; ///< Wire speed following SSD1306 transfers
|
||||
#endif
|
||||
uint8_t contrast; ///< normal contrast setting for this device
|
||||
#if defined(SPI_HAS_TRANSACTION)
|
||||
protected:
|
||||
// Allow sub-class to change
|
||||
SPISettings spiSettings;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // _Adafruit_SSD1306_H_
|
@ -1,4 +1,17 @@
|
||||
/* Arduino Rotator Controller
|
||||
/*
|
||||
AZC notes:
|
||||
|
||||
easyEda: https://easyeda.com/editor#id=a82c5445af594906814706b7dc0fdf6f|e73a62999b1b49efba16c5c9ce2f9027
|
||||
|
||||
|
||||
using https://github.com/adafruit/Adafruit_SSD1306
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Arduino Rotator Controller
|
||||
*
|
||||
|
||||
Anthony Good
|
||||
K3NG
|
||||
@ -1138,6 +1151,8 @@
|
||||
|
||||
#include "rotator_dependencies.h"
|
||||
|
||||
#include <Wire.h>
|
||||
|
||||
#ifdef FEATURE_4_BIT_LCD_DISPLAY
|
||||
#include <LiquidCrystal.h> // required for classic 4 bit interface LCD display (FEATURE_4_BIT_LCD_DISPLAY)
|
||||
#endif
|
||||
@ -1343,7 +1358,7 @@ byte current_az_speed_voltage = 0;
|
||||
double latitude = DEFAULT_LATITUDE;
|
||||
double longitude = DEFAULT_LONGITUDE;
|
||||
double altitude_m = DEFAULT_ALTITUDE_M;
|
||||
byte periodic_debug_dump_time_seconds = 3;
|
||||
byte periodic_debug_dump_time_seconds = 1;
|
||||
|
||||
DebugClass debug;
|
||||
|
||||
@ -1867,7 +1882,9 @@ struct config_t {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void
|
||||
wifiSetup(void);
|
||||
|
||||
/* ------------------ let's start doing some stuff now that we got the formalities out of the way --------------------*/
|
||||
|
||||
void setup() {
|
||||
@ -1888,6 +1905,8 @@ void setup() {
|
||||
|
||||
initialize_interrupts();
|
||||
|
||||
wifiSetup();
|
||||
|
||||
run_this_once();
|
||||
|
||||
|
||||
@ -1895,6 +1914,8 @@ void setup() {
|
||||
|
||||
/*-------------------------- here's where the magic happens --------------------------------*/
|
||||
|
||||
void wifiLoop(void);
|
||||
|
||||
void loop() {
|
||||
|
||||
#ifdef DEBUG_LOOP
|
||||
@ -2093,6 +2114,8 @@ void loop() {
|
||||
check_serial();
|
||||
#endif
|
||||
|
||||
wifiLoop();
|
||||
|
||||
} // loop
|
||||
|
||||
/* -------------------------------------- subroutines -----------------------------------------------
|
||||
@ -7225,9 +7248,9 @@ void read_settings_from_eeprom(){
|
||||
#ifdef DEBUG_EEPROM
|
||||
if (debug_mode) {
|
||||
debug.println("read_settings_from_eeprom: reading settings from eeprom: ");
|
||||
debug.print("\nconfiguration_struct_version"):
|
||||
debug.print("\nconfiguration_struct_version");
|
||||
debug.print(configuration.configuration_struct_version);
|
||||
debug.print("\nconfiguration_struct_subversion"):
|
||||
debug.print("\nconfiguration_struct_subversion");
|
||||
debug.print(configuration.configuration_struct_subversion);
|
||||
debug.print("\nanalog_az_full_ccw");
|
||||
debug.print(configuration.analog_az_full_ccw);
|
||||
@ -9447,7 +9470,7 @@ void output_debug(){
|
||||
#if !defined(TEENSYDUINO)
|
||||
void * HP = malloc(4);
|
||||
if (HP) {free(HP);}
|
||||
unsigned long free = (unsigned long)SP - (unsigned long)HP;
|
||||
unsigned long free = 0; //(unsigned long)SP - (unsigned long)HP;
|
||||
sprintf(tempstring,"%lu",(unsigned long)free);
|
||||
if ((free < 500) || (free > 10000)){
|
||||
debug.print(F("WARNING: Low memory: "));
|
||||
@ -10226,7 +10249,7 @@ void rotator(byte rotation_action, byte rotation_type, byte traceback) {
|
||||
#endif //FEATURE_STEPPER_MOTOR
|
||||
}
|
||||
if (rotate_cw) {
|
||||
digitalWriteEnhanced(rotate_cw, ROTATE_PIN_AZ_ACTIVE_VALUE);
|
||||
digitalWriteEnhanced(rotate_cw, LOW);
|
||||
#if defined(pin_led_cw)
|
||||
digitalWriteEnhanced(pin_led_cw, PIN_LED_ACTIVE_STATE);
|
||||
#endif
|
||||
@ -10237,9 +10260,15 @@ void rotator(byte rotation_action, byte rotation_type, byte traceback) {
|
||||
digitalWriteEnhanced(pin_led_ccw, PIN_LED_INACTIVE_STATE);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
delay(50);
|
||||
|
||||
if (rotate_cw_ccw){
|
||||
digitalWriteEnhanced(rotate_cw_ccw, ROTATE_PIN_AZ_ACTIVE_VALUE);
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG_ROTATOR
|
||||
if (debug_mode) {
|
||||
debug.print(F(" normal_az_speed_voltage:"));
|
||||
@ -10265,15 +10294,15 @@ void rotator(byte rotation_action, byte rotation_type, byte traceback) {
|
||||
if (rotate_cw_ccw_pwm) {
|
||||
analogWriteEnhanced(rotate_cw_ccw_pwm, 0);
|
||||
}
|
||||
if (rotate_cw_ccw){
|
||||
digitalWriteEnhanced(rotate_cw_ccw, ROTATE_PIN_AZ_INACTIVE_VALUE);
|
||||
}
|
||||
if (rotate_cw) {
|
||||
digitalWriteEnhanced(rotate_cw, ROTATE_PIN_AZ_INACTIVE_VALUE);
|
||||
//digitalWriteEnhanced(rotate_cw, ROTATE_PIN_AZ_INACTIVE_VALUE);
|
||||
#if defined(pin_led_cw)
|
||||
digitalWriteEnhanced(pin_led_cw, PIN_LED_INACTIVE_STATE);
|
||||
#endif
|
||||
}
|
||||
if (rotate_cw_ccw){
|
||||
digitalWriteEnhanced(rotate_cw_ccw, ROTATE_PIN_AZ_INACTIVE_VALUE);
|
||||
}
|
||||
if (rotate_cw_freq) {
|
||||
noTone(rotate_cw_freq);
|
||||
}
|
||||
@ -10310,6 +10339,7 @@ void rotator(byte rotation_action, byte rotation_type, byte traceback) {
|
||||
if (rotate_ccw_pwm) {
|
||||
analogWriteEnhanced(rotate_ccw_pwm, 0);
|
||||
}
|
||||
|
||||
if (rotate_cw_ccw_pwm) {
|
||||
analogWriteEnhanced(rotate_cw_ccw_pwm, 0);
|
||||
}
|
||||
@ -10347,8 +10377,11 @@ void rotator(byte rotation_action, byte rotation_type, byte traceback) {
|
||||
}
|
||||
#endif //FEATURE_STEPPER_MOTOR
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (rotate_cw) {
|
||||
digitalWriteEnhanced(rotate_cw, ROTATE_PIN_AZ_INACTIVE_VALUE);
|
||||
digitalWriteEnhanced(rotate_cw, HIGH);
|
||||
#if defined(pin_led_cw)
|
||||
digitalWriteEnhanced(pin_led_cw, PIN_LED_INACTIVE_STATE);
|
||||
#endif
|
||||
@ -10358,10 +10391,14 @@ void rotator(byte rotation_action, byte rotation_type, byte traceback) {
|
||||
#if defined(pin_led_ccw)
|
||||
digitalWriteEnhanced(pin_led_ccw, PIN_LED_ACTIVE_STATE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
delay(50);
|
||||
|
||||
if (rotate_cw_ccw){
|
||||
digitalWriteEnhanced(rotate_cw_ccw, ROTATE_PIN_AZ_ACTIVE_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_ROTATOR
|
||||
if (debug_mode) {
|
||||
debug.print(F(" normal_az_speed_voltage:"));
|
||||
@ -11114,8 +11151,13 @@ void initialize_peripherals(){
|
||||
control_port->flush();
|
||||
#endif // DEBUG_LOOP
|
||||
|
||||
Wire.setSDA(20);
|
||||
Wire.setSCL(21);
|
||||
|
||||
#ifdef FEATURE_WIRE_SUPPORT
|
||||
Wire.begin();
|
||||
|
||||
|
||||
// Wire.begin();
|
||||
#endif
|
||||
|
||||
#ifdef FEATURE_AZ_POSITION_HMC5883L
|
||||
@ -13681,9 +13723,9 @@ byte get_analog_pin(byte pin_number){
|
||||
case 1: return_output = A1; break;
|
||||
case 2: return_output = A2; break;
|
||||
case 3: return_output = A3; break;
|
||||
case 4: return_output = A4; break;
|
||||
case 5: return_output = A5; break;
|
||||
case 6: return_output = A6; break;
|
||||
// case 4: return_output = A4; break;
|
||||
// case 5: return_output = A5; break;
|
||||
// case 6: return_output = A6; break;
|
||||
}
|
||||
|
||||
return return_output;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
|
||||
#define DEFAULT_DEBUG_STATE 0 // 1 = activate debug mode at startup; this should be set to zero unless you're debugging something at startup
|
||||
#define DEFAULT_DEBUG_STATE 1 // 1 = activate debug mode at startup; this should be set to zero unless you're debugging something at startup
|
||||
|
||||
#define DEBUG_DUMP // normally compile with this activated unless you're really trying to save memory
|
||||
// #define DEBUG_LOOP
|
||||
@ -80,4 +80,4 @@
|
||||
// #define DEBUG_SATELLITE_POPULATE_LIST_ARRAY
|
||||
// #define DEBUG_SATELLITE_LIST_EXTRA_INFO
|
||||
// #define DEBUG_SATELLITE_CALC_RESET
|
||||
// #define DEBUG_SATELLITE_USE_OLD_OBSERVER_OBJECT // Deprecated 2022-02-20
|
||||
// #define DEBUG_SATELLITE_USE_OLD_OBSERVER_OBJECT // Deprecated 2022-02-20
|
||||
|
4
k3ng_rotator_controller/rotator_features.h
Executable file → Normal file
4
k3ng_rotator_controller/rotator_features.h
Executable file → Normal file
@ -78,7 +78,7 @@
|
||||
// #define FEATURE_EL_POSITION_A2_ABSOLUTE_ENCODER
|
||||
|
||||
// And if you are using any display other than a 4 bit LCD, you must also change the feature setting in rotator_k3ngdisplay.h!!!!
|
||||
// #define FEATURE_4_BIT_LCD_DISPLAY // Uncomment for classic 4 bit LCD display (most common)
|
||||
#define FEATURE_4_BIT_LCD_DISPLAY // Uncomment for classic 4 bit LCD display (most common)
|
||||
// #define FEATURE_ADAFRUIT_I2C_LCD
|
||||
// #define FEATURE_ADAFRUIT_BUTTONS // Uncomment this to use Adafruit I2C LCD buttons for manual AZ/EL instead of normal buttons (also set this feature in rotator_k3ngdisplay.h)
|
||||
// #define FEATURE_YOURDUINO_I2C_LCD
|
||||
@ -196,4 +196,4 @@
|
||||
|
||||
// #define OPTION_DEPRECATED_NEXTION_INIT_CODE_1 // use only with VK4GHZ Nextion firmware versions previous to 2021-10-23
|
||||
// #define OPTION_DEPRECATED_NEXTION_INIT_CODE_2 // use only with VK4GHZ Nextion firmware versions previous to 2021-10-23
|
||||
// #define OPTION_SEND_NEXTION_RESET_AT_BOOTUP // not for use with OPTION_DEPRECATED_NEXTION_INIT_CODE_1 or OPTION_DEPRECATED_NEXTION_INIT_CODE_2 above
|
||||
// #define OPTION_SEND_NEXTION_RESET_AT_BOOTUP // not for use with OPTION_DEPRECATED_NEXTION_INIT_CODE_1 or OPTION_DEPRECATED_NEXTION_INIT_CODE_2 above
|
||||
|
@ -13,8 +13,8 @@
|
||||
#include "rotator_k3ngdisplay.h"
|
||||
|
||||
#ifdef FEATURE_4_BIT_LCD_DISPLAY
|
||||
#include <LiquidCrystal.h>
|
||||
LiquidCrystal lcd(lcd_4_bit_rs_pin, lcd_4_bit_enable_pin, lcd_4_bit_d4_pin, lcd_4_bit_d5_pin, lcd_4_bit_d6_pin, lcd_4_bit_d7_pin);
|
||||
//#include <LiquidCrystal.h>
|
||||
//LiquidCrystal lcd(lcd_4_bit_rs_pin, lcd_4_bit_enable_pin, lcd_4_bit_d4_pin, lcd_4_bit_d5_pin, lcd_4_bit_d6_pin, lcd_4_bit_d7_pin);
|
||||
#endif // FEATURE_4_BIT_LCD_DISPLAY
|
||||
|
||||
#ifdef FEATURE_WIRE_SUPPORT
|
||||
@ -44,6 +44,10 @@
|
||||
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header
|
||||
#endif
|
||||
|
||||
#include <Adafruit_GFX.h>
|
||||
|
||||
#include "Adafruit_SSD1306.h"
|
||||
|
||||
|
||||
#if defined(FEATURE_YOURDUINO_I2C_LCD)
|
||||
#define I2C_ADDR 0x20
|
||||
@ -126,8 +130,38 @@ K3NGdisplay::K3NGdisplay(int _display_columns, int _display_rows, int _update_ti
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#define SCREEN_WIDTH 128 // 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)
|
||||
// The pins for I2C are defined by the Wire-library.
|
||||
// On an arduino UNO: A4(SDA), A5(SCL)
|
||||
// On an arduino MEGA 2560: 20(SDA), 21(SCL)
|
||||
// On an arduino LEONARDO: 2(SDA), 3(SCL), ...
|
||||
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
|
||||
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
|
||||
|
||||
Adafruit_SSD1306 lcd(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
|
||||
|
||||
void K3NGdisplay::initialize(){
|
||||
|
||||
//Serial.begin(9600);
|
||||
|
||||
|
||||
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
|
||||
if(!lcd.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
|
||||
Serial.println(F("SSD1306 allocation failed"));
|
||||
for(;;); // Don't proceed, loop forever
|
||||
} else {
|
||||
|
||||
Serial.println(F("SSD1306 OK"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
#if !defined(FEATURE_MIDAS_I2C_DISPLAY)
|
||||
lcd.begin(display_columns, display_rows); // if you are getting an error on this line and do not have
|
||||
// any of the LCD display features enabled, remove
|
||||
@ -165,14 +199,28 @@ void K3NGdisplay::initialize(){
|
||||
|
||||
clear();
|
||||
|
||||
*/
|
||||
|
||||
// Clear the buffer
|
||||
lcd.clearDisplay();
|
||||
|
||||
lcd.setTextSize(1); // Normal 1:1 pixel scale
|
||||
lcd.setTextColor(SSD1306_WHITE); // Draw white text
|
||||
lcd.setCursor(0,0); // Start at top-left corner
|
||||
lcd.cp437(false); // Use full 256 char 'Code Page 437' font
|
||||
lcd.println(F("0123456789"));
|
||||
lcd.println(F("0123456789"));
|
||||
lcd.println(F("0123456789"));
|
||||
lcd.println(F("0123456789"));
|
||||
lcd.display();
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------------
|
||||
|
||||
void K3NGdisplay::service(uint8_t force_update_flag = 0){
|
||||
|
||||
|
||||
|
||||
|
||||
// force_update_flag = 1 : force a screen update regardless of update_time_ms, but not if there is a timed message (i.e. revert_screen_flag = 1)
|
||||
// force_update_flag = 2 : force a screen update regardless of update_time_ms and revert_screen_flag
|
||||
|
||||
@ -254,10 +302,12 @@ void K3NGdisplay::clear(){
|
||||
|
||||
}
|
||||
|
||||
lcd.clear();
|
||||
// TODO
|
||||
// lcd.clear();
|
||||
|
||||
#ifdef FEATURE_4_BIT_LCD_DISPLAY
|
||||
lcd.noCursor();
|
||||
// TODO
|
||||
// lcd.noCursor();
|
||||
#endif
|
||||
|
||||
current_print_row = 0;
|
||||
@ -303,7 +353,8 @@ void K3NGdisplay::update(){
|
||||
|
||||
byte wrote_to_lcd_last_loop = 0;
|
||||
|
||||
lcd.noCursor();
|
||||
// TODO
|
||||
//lcd.noCursor();
|
||||
lcd.setCursor(0,0);
|
||||
|
||||
for (int x = 0;x < (display_columns*display_rows);x++){
|
||||
@ -356,7 +407,8 @@ void K3NGdisplay::redraw(){
|
||||
|
||||
// redraw the screen with the current screen_buffer_live
|
||||
|
||||
lcd.noCursor();
|
||||
// TODO
|
||||
//lcd.noCursor();
|
||||
lcd.setCursor(0,0);
|
||||
|
||||
for (int x = 0;x < (display_columns*display_rows);x++){
|
||||
@ -372,6 +424,8 @@ void K3NGdisplay::redraw(){
|
||||
}
|
||||
}
|
||||
|
||||
lcd.display();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -814,4 +868,3 @@ uint8_t K3NGdisplay::readButtons(){
|
||||
|
||||
|
||||
#endif //K3NG_DISPLAY_H
|
||||
|
||||
|
13
k3ng_rotator_controller/rotator_pins.h
Executable file → Normal file
13
k3ng_rotator_controller/rotator_pins.h
Executable file → Normal file
@ -10,18 +10,18 @@
|
||||
|
||||
/* azimuth pins --------------------- (use just the azimuth pins for an azimuth-only rotator) */
|
||||
|
||||
#define rotate_cw 6 // goes high to activate rotator R (CW) rotation - pin 1 on Yaesu connector
|
||||
#define rotate_ccw 7 // goes high to activate rotator L (CCW) rotation - pin 2 on Yaesu connector
|
||||
#define rotate_cw_ccw 0 // goes high for both CW and CCW rotation
|
||||
#define rotate_cw 16 // goes high to activate rotator R (CW) rotation - pin 1 on Yaesu connector
|
||||
#define rotate_ccw 0 // goes high to activate rotator L (CCW) rotation - pin 2 on Yaesu connector
|
||||
#define rotate_cw_ccw 17 // goes high for both CW and CCW rotation
|
||||
#define rotate_cw_pwm 0 // optional - PWM CW output - set to 0 to disable (must be PWM capable pin)
|
||||
#define rotate_ccw_pwm 0 // optional - PWM CCW output - set to 0 to disable (must be PWM capable pin)
|
||||
#define rotate_cw_ccw_pwm 0 // optional - PWM on CW and CCW output - set to 0 to disable (must be PWM capable pin)
|
||||
#define rotate_cw_freq 0 // optional - CW variable frequency output
|
||||
#define rotate_ccw_freq 0 // optional - CCW variable frequency output
|
||||
#define button_cw 0 // normally open button to ground for manual CW rotation (schematic pin: A2)
|
||||
#define button_ccw 0 // normally open button to ground for manual CCW rotation (schematic pin: A3)
|
||||
#define button_cw 14 // normally open button to ground for manual CW rotation (schematic pin: A2)
|
||||
#define button_ccw 15 // normally open button to ground for manual CCW rotation (schematic pin: A3)
|
||||
#define serial_led 0 // LED blinks when command is received on serial port (set to 0 to disable)
|
||||
#define rotator_analog_az A0 // reads analog azimuth voltage from rotator - pin 4 on Yaesu connector
|
||||
#define rotator_analog_az 26 // reads analog azimuth voltage from rotator - pin 4 on Yaesu connector
|
||||
#define azimuth_speed_voltage 0 // optional - PWM output for speed control voltage feed into rotator (on continually unlike rotate_cw_pwm and rotate_ccw_pwm)
|
||||
#define overlap_led 0 // line goes active when azimuth rotator is in overlap (> 360 rotators)
|
||||
#define brake_az 0 // goes high to disengage azimuth brake (set to 0 to disable)
|
||||
@ -235,4 +235,3 @@
|
||||
#define satellite_tracking_active_pin 0
|
||||
#define satellite_tracking_activate_line 0
|
||||
#define satellite_tracking_button 0 // use with a normally open momentary switch to ground
|
||||
|
||||
|
8
k3ng_rotator_controller/rotator_settings.h
Executable file → Normal file
8
k3ng_rotator_controller/rotator_settings.h
Executable file → Normal file
@ -243,13 +243,9 @@ You can tweak these, but read the online documentation!
|
||||
|
||||
#define POWER_SWITCH_IDLE_TIMEOUT 15 // use with FEATURE_POWER_SWITCH; units are minutes
|
||||
|
||||
#ifdef HARDWARE_EA4TX_ARS_USB
|
||||
|
||||
#define BUTTON_ACTIVE_STATE HIGH
|
||||
#define BUTTON_INACTIVE_STATE LOW
|
||||
#else
|
||||
#define BUTTON_ACTIVE_STATE LOW
|
||||
#define BUTTON_INACTIVE_STATE HIGH
|
||||
#endif
|
||||
|
||||
/*
|
||||
*
|
||||
@ -389,5 +385,3 @@ You can tweak these, but read the online documentation!
|
||||
#define SATELLITE_CALC_STAGE_3_RESOLUTION_SECS 1
|
||||
|
||||
#define NEXTION_GSC_STARTUP_DELAY 0
|
||||
|
||||
|
||||
|
146
k3ng_rotator_controller/wifi.cpp
Normal file
146
k3ng_rotator_controller/wifi.cpp
Normal file
@ -0,0 +1,146 @@
|
||||
|
||||
|
||||
#include <WiFi.h>
|
||||
#include <WiFiClient.h>
|
||||
#include <WebServer.h>
|
||||
#include <LEAmDNS.h>
|
||||
#include <string>
|
||||
|
||||
#ifndef STASSID
|
||||
#define STASSID "ENRICO"
|
||||
#define STAPSK "cqdxcqdx"
|
||||
#endif
|
||||
|
||||
const char* ssid = STASSID;
|
||||
const char* password = STAPSK;
|
||||
|
||||
WebServer server(80);
|
||||
|
||||
|
||||
extern float azimuth;
|
||||
extern float raw_azimuth;
|
||||
extern int analog_az;
|
||||
|
||||
void handleRoot() {
|
||||
|
||||
std::string reply = "Pico W rotator<br/>";
|
||||
|
||||
reply += "Azimuth: " + std::to_string(azimuth) + "<br/>";
|
||||
reply += "Raw Azimuth: " + std::to_string(raw_azimuth) + "<br/>";
|
||||
reply += "Analog Azimuth: " + std::to_string(analog_az) + "<br/>";
|
||||
|
||||
server.send(200, "text/html", reply.c_str());
|
||||
}
|
||||
|
||||
|
||||
void handleNotFound() {
|
||||
String message = "File Not Found\n\n";
|
||||
message += "URI: ";
|
||||
message += server.uri();
|
||||
message += "\nMethod: ";
|
||||
message += (server.method() == HTTP_GET) ? "GET" : "POST";
|
||||
message += "\nArguments: ";
|
||||
message += server.args();
|
||||
message += "\n";
|
||||
for (uint8_t i = 0; i < server.args(); i++) {
|
||||
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
|
||||
}
|
||||
server.send(404, "text/plain", message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void wifiSetup(void) {
|
||||
|
||||
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(ssid, password);
|
||||
Serial.println("");
|
||||
|
||||
// Wait for connection
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
Serial.print(".");
|
||||
}
|
||||
Serial.println("");
|
||||
Serial.print("Connected to ");
|
||||
Serial.println(ssid);
|
||||
Serial.print("IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
|
||||
if (MDNS.begin("picow")) {
|
||||
Serial.println("MDNS responder started");
|
||||
}
|
||||
|
||||
server.on("/", handleRoot);
|
||||
|
||||
server.on("/inline", []() {
|
||||
server.send(200, "text/plain", "this works as well");
|
||||
});
|
||||
|
||||
server.onNotFound(handleNotFound);
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
// Hook examples
|
||||
|
||||
server.addHook([](const String & method, const String & url, WiFiClient * client, WebServer::ContentTypeFunction contentType) {
|
||||
(void)method; // GET, PUT, ...
|
||||
(void)url; // example: /root/myfile.html
|
||||
(void)client; // the webserver tcp client connection
|
||||
(void)contentType; // contentType(".html") => "text/html"
|
||||
Serial.println("A useless web hook has passed:");
|
||||
Serial.println(method);
|
||||
Serial.println(url);
|
||||
//Serial.println(contentType);
|
||||
return WebServer::CLIENT_REQUEST_CAN_CONTINUE;
|
||||
});
|
||||
|
||||
server.addHook([](const String&, const String & url, WiFiClient*, WebServer::ContentTypeFunction) {
|
||||
if (url.startsWith("/fail")) {
|
||||
Serial.printf("An always failing web hook has been triggered\n");
|
||||
return WebServer::CLIENT_MUST_STOP;
|
||||
}
|
||||
return WebServer::CLIENT_REQUEST_CAN_CONTINUE;
|
||||
});
|
||||
|
||||
server.addHook([](const String&, const String & url, WiFiClient * client, WebServer::ContentTypeFunction) {
|
||||
if (url.startsWith("/dump")) {
|
||||
Serial.printf("The dumper web hook is on the run\n");
|
||||
|
||||
// Here the request is not interpreted, so we cannot for sure
|
||||
// swallow the exact amount matching the full request+content,
|
||||
// hence the tcp connection cannot be handled anymore by the
|
||||
auto last = millis();
|
||||
while ((millis() - last) < 500) {
|
||||
char buf[32];
|
||||
size_t len = client->read((uint8_t*)buf, sizeof(buf));
|
||||
if (len > 0) {
|
||||
Serial.printf("(<%d> chars)", (int)len);
|
||||
Serial.write(buf, len);
|
||||
last = millis();
|
||||
}
|
||||
}
|
||||
// Two choices: return MUST STOP and webserver will close it
|
||||
// (we already have the example with '/fail' hook)
|
||||
// or IS GIVEN and webserver will forget it
|
||||
// trying with IS GIVEN and storing it on a dumb WiFiClient.
|
||||
// check the client connection: it should not immediately be closed
|
||||
// (make another '/dump' one to close the first)
|
||||
Serial.printf("\nTelling server to forget this connection\n");
|
||||
static WiFiClient forgetme = *client; // stop previous one if present and transfer client refcounter
|
||||
return WebServer::CLIENT_IS_GIVEN;
|
||||
}
|
||||
return WebServer::CLIENT_REQUEST_CAN_CONTINUE;
|
||||
});
|
||||
|
||||
// Hook examples
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
server.begin();
|
||||
Serial.println("HTTP server started");
|
||||
}
|
||||
|
||||
void wifiLoop(void) {
|
||||
server.handleClient();
|
||||
MDNS.update();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user