This ESP32 firmware project turns your microcontroller into a satellite tracking station with GPS integration. The system features a touchscreen interface for configuration, WiFi connectivity for real-time satellite data, and GPS positioning to display which satellites are visible overhead.
This guide provides the complete firmware, wiring diagram for connecting the ILI9341 display and XPT2046 touchscreen, and step-by-step assembly instructions. You'll flash the firmware via USB, calibrate the display, configure WiFi, select a satellite to track, and verify GPS functionality—all through an intuitive on-screen menu.
Wiring diagram

Assemble it in 4 steps
1. Instala el firmware por USB
Usa un cable USB de datos para esta instalacion. En uso normal no necesita estar conectado al PC. No hacen falta cables internos ni tarjeta microSD.
2. Calibra la pantalla vertical
Al arrancar, toca los tres puntos amarillos. La bitacora existente se conserva.
3. Conecta el WiFi desde la pantalla
Desde Sat Tracker, abre Menu, elige WiFi y pulsa Buscar redes. Elige tu red de 2.4 GHz. Si pide clave, usa Cambiar para alternar entre letras, numeros y simbolos. El primer boton de la pagina de simbolos escribe un espacio. Pulsa Conectar. Al apagar y encender el equipo intentara reconectarse a la ultima red guardada; Olvidar borra la clave guardada de la aplicacion.
4. Elige un satelite y comprueba el GPS
Conecta el WiFi para descargar la orbita inicial. Si tu Marauder tiene receptor GPS, llevalo al exterior y espera a que aparezca GPS con tu locator. El v6.1 de serie no incluye receptor; si no tienes la expansion, introduce un locator manual. Sat Tracker abre al encender y muestra globo y radar juntos. Pulsa Satelites para elegir otro objeto. En Menu puedes cambiar el idioma y abrir Ham Desk al final.
Deploy the firmware
// Aumentar el último número con cada cambio entregado.
constexpr char projectVersion[] = "1.0.1";
#include <sys/time.h>
#include <Arduino.h>
#include <Adafruit_ILI9341.h>
#include <XPT2046_Touchscreen.h>
#include <SPI.h>
#include <Preferences.h>
#include <math.h>
#include <WiFi.h>
#include <HTTPClient.h>
#include <WiFiClientSecure.h>
#include <ArduinoJson.h>
#include <time.h>
#include "gps.h"
#include "labels.h"
Adafruit_ILI9341 t(17,16,5);
XPT2046_Touchscreen ts(21);
// Compose off-screen, then send only changed rows. Keep RGB565 on direct fallback.
class ScreenBuffer : public Adafruit_GFX {
public:
static constexpr int band=32;
static constexpr int height=band;
uint8_t* data(){return pixels;}
int top=0;
uint8_t pixels[240*band];
ScreenBuffer():Adafruit_GFX(240,320){}
void drawPixel(int16_t x,int16_t y,uint16_t c) override {
if(x>=0&&x<240&&y>=top&&y<top+height)
data()[(y-top)*240+x]=((c>>8)&0xe0)|((c>>6)&0x1c)|((c>>3)&3);
}
void writeFillRect(int16_t x,int16_t y,int16_t w,int16_t h,uint16_t c) override {
int left=max(0,int(x)),right=min(240,int(x)+w);
int first=max(top,int(y)),end=min(top+height,int(y)+h);
if(right<=left)return;
uint8_t packed=((c>>8)&0xe0)|((c>>6)&0x1c)|((c>>3)&3);
for(int row=first;row<end;++row)memset(data()+(row-top)*240+left,packed,right-left);
}
void fillRect(int16_t x,int16_t y,int16_t w,int16_t h,uint16_t c) override {writeFillRect(x,y,w,h,c);}
void writeFastHLine(int16_t x,int16_t y,int16_t w,uint16_t c) override {writeFillRect(x,y,w,1,c);}
void writeFastVLine(int16_t x,int16_t y,int16_t h,uint16_t c) override {writeFillRect(x,y,1,h,c);}
void fillScreen(uint16_t c) override {memset(data(),((c>>8)&0xe0)|((c>>6)&0x1c)|((c>>3)&3),240*height);}
void flush(){
static uint32_t previous[320];
static bool sent[320];
uint16_t row[240];t.startWrite();
for(int y=top;y<top+height;++y){
const uint8_t* p=data()+(y-top)*240;uint32_t hash=2166136261u;
for(int x=0;x<240;++x)hash=(hash^p[x])*16777619u;
if(sent[y]&&hash==previous[y])continue;
previous[y]=hash;sent[y]=true;
for(int x=0;x<240;++x){unsigned c=p[x];row[x]=((c>>5)*31/7<<11)|(((c>>2)&7)*63/7<<5)|((c&3)*31/3);}
t.setAddrWindow(0,y,240,1);t.writePixels(row,240);
}
t.endWrite();
}
};
ScreenBuffer frame;
Adafruit_GFX& ui=frame;
struct Cal { int32_t x0,y0,dx,dy; bool swap; } cal{};
Preferences prefs;
struct Contact { char call[13]; char freq[11]; char mode[6]; };
constexpr unsigned MAX=60;
Contact logs[MAX]{};
unsigned count=0, pos=0;
bool store=false;
enum Page { HOME, CALL, FREQ, MODE, LOG, CALC, RESULT, TOOLS, SOTA, DX, SOLAR, WLAN, WLAN_KEY, SAT, SAT_GRID, SAT_PICK, GPS_STATUS, LANG } page=SAT;
String input, call, freq, status;
double mhz=0;
const char keys[]="1234567890QWERTYUIOPASDFGHJKL.ZXCVBNM/-_";
const char* modes[]={"FM","SSB","CW","DIGI"};
bool linked=false;
int scanState=-2, netOffset=0, keyBank=0;
bool scanning=false, joining=false;
uint32_t joinAt=0;
String netName, netKey, netMessage, savedSSID, savedKey;
String locator;
uint32_t nextOnline=0;
uint32_t wifiRetry=0;
struct NetworkProfile { char ssid[33]; char key[64]; };
constexpr uint16_t panel=0x214d, edge=0x43f5, accent=0x4eff;
void text(int x,int y,const String& raw,int scale=2){
if(y>=frame.top+frame.height||y+8*scale<=frame.top)return;
String s=local(raw.c_str());int n=(236-x)/(6*scale);
if(n<=0)return;
if(int(s.length())>n)s=n>=4?s.substring(0,n-3)+"...":s.substring(0,n);
ui.setTextSize(scale);ui.setCursor(x,y);ui.print(s);
}
void button(int x,int y,int w,int h,const char* raw,int scale=2){
if(y>=frame.top+frame.height||y+h<=frame.top)return;
const char* s=local(raw);int len=strlen(s);
if(!len)return;
if(len*6*scale>w-8)scale=1;
String label(s);int n=(w-8)/(6*scale);
if(n<1)return;
if(len>n)label=n>=4?label.substring(0,n-3)+"...":label.substring(0,n);
ui.fillRoundRect(x,y,w,h,8,y==274?0x2259:panel);
ui.drawFastHLine(x+8,y+h-2,w-16,edge);
ui.setTextSize(scale);
ui.setCursor(x+(w-int(label.length())*6*scale)/2,y+(h-8*scale)/2);
ui.print(label);
}
void footer(const char* b,const char* c){button(2,274,72,40,"Inicio");button(80,274,78,40,b);button(162,274,76,40,c);}
void header(const String& title){
ui.fillRect(0,0,240,35,0x192c);
ui.fillRoundRect(6,8,3,19,1,accent);text(15,10,title,strlen(local(title.c_str()))>15?1:2);
ui.drawFastHLine(6,34,228,edge);
}
void grid(int i,const char* label){button(7+(i%2)*116,48+(i/2)*49,110,42,label);}
int gridHit(int x,int y,int rows){
if(y<48||y>=48+rows*49||(y-48)%49>=42)return -1;
if(x>=7&&x<117)return 2*((y-48)/49);
if(x>=123&&x<233)return 2*((y-48)/49)+1;
return -1;
}
void onlineDraw();
void satelliteMenu();
extern int satPage, selectedSat;
extern const int satCount, satPages;
void selectOrbit(int);
void prepareSatFrame();
const char* passSatellite();
void networkTick();
void networkSetup();
char passwordChar(int i){int c=32+keyBank*32+i;return c<=126?char(c):0;}
void wifiDraw(){
header(page==WLAN?"REDES WiFi":"CLAVE WiFi");
if(page==WLAN_KEY){
text(8,45,netName.substring(0,36),1);text(157,64,"_ = espacio",1);
String mask;for(unsigned i=0;i<min(24u,netKey.length());i++)mask+='*';
text(8,64,mask.substring(0,17)+" ("+String(netKey.length())+")",1);
for(int i=0;i<32;i++){char k=passwordChar(i);if(k){char label[]={k==' '?'_':k,0};button(4+(i%8)*29,85+(i/8)*39,27,36,label);}}
button(4,245,72,25,"Cambiar",1);button(82,245,76,25,"Borrar",1);
footer("Volver","Conectar");return;
}
text(8,43,linked?WiFi.SSID().substring(0,36):"Sin conexion",1);
text(8,57,linked?WiFi.localIP().toString():"2.4 GHz / WPA2",1);
text(8,74,netMessage,1);
if(!scanning&&!joining)for(int row=0;row<4&&netOffset+row<scanState;row++){
int i=netOffset+row,y=90+row*36;
ui.fillRoundRect(6,y,228,32,4,0x192c);
text(12,y+5,WiFi.SSID(i).substring(0,35),1);
text(12,y+18,String(WiFi.RSSI(i))+" dBm / "+(WiFi.encryptionType(i)==WIFI_AUTH_OPEN?"Abierta":"Protegida"),1);
}
button(4,239,72,29,"Anterior",1);button(82,239,76,29,"Siguiente",1);button(164,239,72,29,savedSSID.length()?"Olvidar":"",1);
button(2,274,72,40,"Inicio");button(80,274,158,40,"Buscar redes");
}
void startScan(){
if(scanning||joining)return;
if(!linked)WiFi.disconnect();
WiFi.mode(WIFI_STA);WiFi.scanDelete();netOffset=0;
scanState=WiFi.scanNetworks(true);scanning=scanState==WIFI_SCAN_RUNNING;
netMessage=scanning?"Buscando redes...":"No se pudo buscar. Reintenta.";
}
void joinNetwork(){
WiFi.mode(WIFI_STA);WiFi.setAutoReconnect(false);WiFi.disconnect();
WiFi.begin(netName.c_str(),netKey.c_str());joining=true;joinAt=millis();
netMessage="Conectando...";page=WLAN;
}
void gpsDraw(){
header("ESTADO GPS");
int fix=gpsFixType();
ui.setTextColor(fix==3?ILI9341_GREEN:ILI9341_YELLOW);
text(8,43,fix==3?"FIX 3D":fix==2?"FIX 2D":gpsFix()?"Posicion / sin modo":gpsData?"Buscando fix":"Sin datos GPS");
ui.setTextColor(ILI9341_WHITE);
text(156,47,gpsGrid(),1);
constexpr int cx=120,cy=119,r=48;
for(int ring:{16,32,r})ui.drawCircle(cx,cy,ring,0x738e);
ui.drawFastHLine(cx-r,cy,r*2+1,0x738e);ui.drawFastVLine(cx,cy-r,r*2+1,0x738e);
text(117,62,"N",1);text(174,115,"E",1);text(117,169,"S",1);text(60,115,"O",1);
int seen=0;
for(auto& s:sky)if(skyFresh(s)){
++seen;
float a=s.az*DEG_TO_RAD,d=r*(90-s.el)/90.f;
int x=cx+lround(d*sin(a)),y=cy-lround(d*cos(a));
uint16_t color=s.snr>0?ILI9341_YELLOW:0x738e;
ui.fillCircle(x,y,3,color);text(x+3,y-6,String(s.id),1);
}
int i=0;
for(auto& s:sky)if(skyFresh(s)){
int step=224/max(1,seen),x=8+i++*step,h=constrain(s.snr,0,50)*24/50;
ui.fillRect(x,183,step-1,24,0x738e);
if(h)ui.fillRect(x,207-h,step-1,h,ILI9341_YELLOW);
}
text(8,214,String("Usados: ")+(gps.satellites.isValid()&&gps.satellites.age()<5000?String(gps.satellites.value()):"--")+" / En mapa: "+seen,1);
text(8,229,gpsFix()?String(gps.location.lat(),5)+" / "+String(gps.location.lng(),5):"Sin coordenadas actuales",1);
text(8,244,String("Alt: ")+(fix==3&&gps.altitude.isValid()&&gps.altitude.age()<5000?String(gps.altitude.meters(),0)+" m":"--")+" HDOP: "+(gpsFix()&&gps.hdop.isValid()&&gps.hdop.age()<5000?String(gps.hdop.hdop(),1):"--"),1);
char utc[24]="UTC --:--:--";
if(gps.time.isValid()&&gps.time.age()<5000)snprintf(utc,sizeof(utc),"UTC %02u:%02u:%02u",gps.time.hour(),gps.time.minute(),gps.time.second());
text(8,259,utc,1);
button(2,274,72,40,"Inicio");button(80,274,78,40,"Volver");
// Ground speed from a recent GPS fix, shown in both unit systems.
const bool speedFresh=gpsFix()&&gps.speed.isValid()&&gps.speed.age()<3000;
ui.fillRoundRect(164,274,72,40,5,panel);
ui.drawRoundRect(164,274,72,40,5,edge);
text(169,278,"Velocidad",1);
ui.setTextColor(accent);
text(169,289,(speedFresh?String(gps.speed.kmph(),1):String("--"))+" km/h",1);
text(169,300,(speedFresh?String(gps.speed.mph(),1):String("--"))+" mph",1);
ui.setTextColor(ILI9341_WHITE);
}
void compose(){
ui.setTextWrap(false);ui.fillScreen(0x0842);ui.setTextColor(ILI9341_WHITE);
if(page==GPS_STATUS){gpsDraw();return;}
if(page==SAT_PICK){satelliteMenu();return;}
if(page==WLAN||page==WLAN_KEY){wifiDraw();return;}
if(page==DX||page==SOLAR||page==SOTA||page==SAT){onlineDraw();return;}
if(page==HOME){header("HAM DESK");
grid(0,"Nuevo QSO");grid(1,"Bitacora");grid(2,"Antenas");grid(3,"WiFi");
ui.fillRoundRect(7,154,226,101,6,panel);text(16,168,"ESTADO DE ESTACION",1);
text(16,190,String("QSO ")+count+" / "+MAX);text(16,219,gpsFix()?"GPS "+gpsGrid():"GPS sin fix",1);
if(status.length())text(16,238,status,1);
footer("Menu","");return;}
if(page==TOOLS){header("UTILIDADES");grid(0,"WiFi");grid(1,"GPS Fix");grid(2,"Cluster DX");grid(3,"Solar HF");grid(4,"SOTA");grid(5,"Idioma");button(2,274,72,40,"Inicio");return;}
if(page==LANG){header("IDIOMA");const char* names[]={"Espanol","English","Francais"};
for(int i=0;i<3;i++){button(12,58+i*58,216,46,names[i]);if(language==i)ui.fillCircle(29,81+i*58,4,accent);}
footer("Volver","");return;}
if(page==LOG){header("BITACORA / QSO");if(count){const auto& a=logs[pos];text(8,46,String(pos+1)+" / "+count);text(8,80,a.call,3);text(8,120,String(a.freq)+" MHz");text(8,152,a.mode);}else text(8,55,"Sin contactos");footer("Ant.","Sig.");return;}
if(page==RESULT){header("ANTENAS / "+String(mhz,3)+" MHz");text(8,47,"Onda libre: "+String(299.792458/mhz,3)+" m");text(8,76,"Dipolo: "+String(143.0/mhz,3)+" m");text(8,105,"Cada brazo: "+String(71.5/mhz,3)+" m");text(8,134,"Vertical*: "+String(74.9481145/mhz,3)+" m");text(8,163,"*1/4 de onda ideal. Ajusta midiendo ROE.",1);button(2,274,72,40,"Inicio");button(80,274,78,40,"Volver");button(162,274,76,40,"Otro");return;}
if(page==MODE){text(8,10,"Elige modo y guarda");for(int i=0;i<4;i++) button(8+(i%2)*116,54+(i/2)*65,108,52,modes[i]);button(2,274,72,40,"Inicio");return;}
text(8,6,page==CALL?"Indicativo":page==SAT_GRID?"Locator (ej. IN80)":"Frecuencia en MHz");text(8,31,input+"_");
for(unsigned i=0;i<40;i++){char k=keys[i]; if(page!=CALL && page!=SAT_GRID && !(i<10||k=='.'))continue;char label[]={k,0};button((i%10)*24+1,54+(i/10)*45,22,40,label);}
footer("Borrar",page==CALC?"Calcular":"Aceptar");
}
// Transfer only the icon rectangle; don't repaint the menu to animate it.
void wifiIcon(bool force=false){
static GFXcanvas16 icon(24,24);
static int previous=-1;
const unsigned phase=millis()/350;
const int state=linked?int(phase%3):3+int(phase%2);
if(!force&&state==previous)return;
previous=state;
icon.fillScreen(0x192c);
for(int band=0;band<3;++band){
const int r=5+band*4;
const uint16_t color=linked&&band<=state?ILI9341_GREEN:0x738e;
for(int x=-r+3;x<=r-3;++x){
const int y=19-int(sqrtf(float(r*r-x*x))+0.5f);
icon.drawFastVLine(12+x,y,2,color);
}
}
icon.fillCircle(12,19,2,linked?ILI9341_GREEN:0x738e);
if(!linked){
icon.drawLine(4,4,20,21,0x192c);
icon.drawLine(3,4,19,21,state==3?ILI9341_RED:0xF986);
}
if(icon.getBuffer())t.drawRGBBitmap(215,4,icon.getBuffer(),24,24);
}
uint32_t animationFrame;
void draw(bool animationOnly=false){
if(page==SAT)prepareSatFrame();
animationFrame=millis()/125;
for(frame.top=animationOnly?64:0;frame.top<(animationOnly?192:320);frame.top+=frame.height){compose();
if(const char* name=passSatellite()){
ui.fillRect(0,0,240,35,0x0260);
text(8,5,"PASE SOBRE TU HORIZONTE",1);
text(8,18,String(name)+" | Prediccion",1);
}
frame.flush();}
if(!animationOnly)wifiIcon(true);
}
void save(int mode){
Contact a{};call.toCharArray(a.call,sizeof(a.call));freq.toCharArray(a.freq,sizeof(a.freq));strlcpy(a.mode,modes[mode],sizeof(a.mode));
if(!store||count==MAX){status=count==MAX?"Bitacora llena (60 contactos)":"Memoria no disponible";page=HOME;return;}
logs[count]=a;
if(prefs.putBytes("qsos",logs,(count+1)*sizeof(Contact))==(count+1)*sizeof(Contact)){ ++count;status="Contacto guardado"; }else status="No se pudo guardar";
page=HOME;
}
void tap(int x,int y){
if(y>=274&&y<314&&x>=2&&x<74&&page!=SAT){netKey="";page=SAT;}
else if(page==HOME){
if(y>=274&&y<314&&x>=80&&x<158)page=TOOLS;
else switch(gridHit(x,y,2)){case 0:page=CALL;input="";break;case 1:page=LOG;pos=count?count-1:0;break;case 2:page=CALC;input="";break;case 3:page=WLAN;if(scanState==-2)startScan();break;default:return;}
}
else if(page==LANG){
if(y>=274&&y<314&&x>=80&&x<158)page=TOOLS;
else if(x>=12&&x<228&&y>=58&&y<220&&(y-58)%58<46){language=(y-58)/58;if(store)prefs.putUChar("uiLang",language);}
else return;
}
else if(page==WLAN){
if(y>=274&&x>=80)startScan();
else if(scanning||joining)return;
else if(y>=239&&y<268){
if(x<76&&netOffset>=4)netOffset-=4;
else if(x>=82&&x<158&&netOffset+4<scanState)netOffset+=4;
else if(x>=164&&savedSSID.length()){WiFi.setAutoReconnect(false);WiFi.disconnect();savedSSID="";savedKey="";if(store){prefs.remove("network");prefs.remove("ssid");prefs.remove("wifi");}netMessage="Red guardada eliminada";}
else return;
}else if(y>=90&&y<234&&(y-90)%36<32&&netOffset+(y-90)/36<scanState){
int i=netOffset+(y-90)/36;netName=WiFi.SSID(i);netKey="";keyBank=1;
if(!netName.length())return;
if(WiFi.encryptionType(i)==WIFI_AUTH_OPEN)joinNetwork();else page=WLAN_KEY;
}else return;
}
else if(page==WLAN_KEY){
if(y>=274&&x>=80&&x<158){netKey="";page=WLAN;}
else if(y>=274&&x>=162){if(netKey.length()<8)return;joinNetwork();}
else if(y>=245&&y<270&&x<76)keyBank=(keyBank+1)%3;
else if(y>=245&&y<270&&x>=82&&x<158&&netKey.length())netKey.remove(netKey.length()-1);
else if(y>=85&&y<241&&x>=4&&x<236&&(y-85)%39<36&&(x-4)%29<27){char c=passwordChar((y-85)/39*8+(x-4)/29);if(!c||netKey.length()>=63)return;netKey+=c;}
else return;
}
else if(page==TOOLS){
switch(gridHit(x,y,4)){case 0:page=WLAN;if(scanState==-2)startScan();break;case 1:page=GPS_STATUS;break;case 2:page=DX;nextOnline=millis();break;case 3:page=SOLAR;nextOnline=millis();break;case 4:page=SOTA;nextOnline=millis();break;case 5:page=LANG;break;default:return;}
}
else if(page==SAT_PICK){if(y>=274&&x>=80&&x<158)page=SAT;else if(y>=274&&x>=162){satPage=(satPage+1)%satPages;}else {int i=gridHit(x,y,4);if(i<0||satPage*8+i>=satCount)return;selectOrbit(satPage*8+i);page=SAT;}}
else if(page==DX||page==SOLAR||page==SOTA||page==SAT){
if(y>=274&&y<314&&page==SAT&&x>=2&&x<155)page=TOOLS;
else if(y>=274&&y<314&&x>=80&&x<158)page=TOOLS;
else if(y>=274&&x>=162&&page==SAT){satPage=selectedSat/8;page=SAT_PICK;}
else if(y>=242&&y<266&&x>=4&&x<116&&page==SAT){input=locator;page=SAT_GRID;}
else if(y>=239&&y<268&&(page==DX||page==SOLAR||page==SOTA))nextOnline=millis();
else return;
}
else if(page==GPS_STATUS){if(y>=274&&x>=80&&x<158)page=TOOLS;else return;}
else if(page==LOG){if(y<274||!count)return;unsigned before=pos;if(x>=162&&pos+1<count)++pos;else if(x>=80&&x<158&&pos)--pos;if(before==pos)return;}
else if(page==RESULT){if(y<274)return;if(x>=162){page=CALC;input="";}else if(x>=80&&x<158)page=CALC;else return;}
else if(page==MODE){if(x<8||x>=232)return;int row=y>=119&&y<171?1:y>=54&&y<106?0:-1;if(row<0)return;save(row*2+(x>=124));}
else if(y>=274){
if(x>=80&&x<158&&input.length())input.remove(input.length()-1);
else if(x>=162&&input.length()){
if(page==SAT_GRID){
if(input.length()!=4||input[0]<'A'||input[0]>'R'||input[1]<'A'||input[1]>'R'||!isDigit(input[2])||!isDigit(input[3]))return;
locator=input;if(store)prefs.putString("satgrid",locator);page=SAT;
}else if(page==CALL){call=input;input="";page=FREQ;}
else {double v=input.toDouble(); if(v<0.1||v>30000)return; mhz=v;if(page==CALC)page=RESULT;else{freq=input;page=MODE;}}
}else return;
}else if(y>=54&&y<234&&x%24>=1&&x%24<23&&(y-54)%45<40){unsigned i=(y-54)/45*10+x/24;char k=keys[i];if(page==CALL||page==SAT_GRID){if(input.length()>=(page==CALL?12:4))return;}else if(input.length()>=10||!(i<10||(k=='.'&&input.indexOf('.')<0)))return;input+=k;}else return;
draw();
}
TS_Point target(int x,int y){
t.fillScreen(ILI9341_BLACK);t.setTextColor(ILI9341_WHITE);t.setTextSize(2);t.setCursor(43,139);t.print("Toca el punto");
t.fillCircle(x,y,7,ILI9341_YELLOW);
while(!ts.touched())delay(10);
delay(70);TS_Point p=ts.getPoint();
while(ts.touched())delay(10);
delay(100);return p;
}
void calibrate(){
do {
auto a=target(18,18), b=target(221,18), c=target(18,301);
cal.swap=abs(b.y-a.y)>abs(b.x-a.x);
cal.x0=cal.swap?a.y:a.x;cal.y0=cal.swap?a.x:a.y;
cal.dx=(cal.swap?b.y:b.x)-cal.x0;cal.dy=(cal.swap?c.x:c.y)-cal.y0;
}while(abs(cal.dx)<800||abs(cal.dy)<800);
if(store)prefs.putBytes("calPortrait",&cal,sizeof(cal));
}
// Boot artwork uses the same 32-row buffer as the tracker.
static bool welcomeActive=false;
static uint32_t welcomeStarted;
static void welcome(){
constexpr uint16_t deep=0x0845, grid=0x22CC, cyan=0x07FF, lime=0xAFE5;
for(frame.top=0;frame.top<320;frame.top+=ScreenBuffer::band){
for(int y=frame.top;y<frame.top+ScreenBuffer::band;++y)
frame.drawFastHLine(0,y,240,y<192?deep:0x0863);
frame.drawRoundRect(10,10,220,300,14,grid);
for(int j=0;j<28;++j)frame.drawPixel(23+(j*73)%194,42+(j*37)%143,grid);
for(int r=20;r<=60;r+=20)frame.drawCircle(120,109,r,grid);
frame.drawFastHLine(53,109,134,grid);
frame.drawFastVLine(120,42,134,grid);
int px=0,py=0;
for(int j=0;j<=24;++j){
int x=62+j*5,y=83+(j-12)*(j-12)/3-j;
if(j)frame.drawLine(px,py,x,y,cyan);
px=x;py=y;
}
frame.fillCircle(152,79,5,lime);
frame.drawCircle(152,79,9,cyan);
frame.setFont(nullptr);frame.setTextWrap(false);
frame.setTextColor(cyan);frame.setTextSize(1);frame.setCursor(75,25);frame.print("MARAUDER / V6.1");
frame.setTextColor(0xFFFF);frame.setTextSize(3);frame.setCursor(21,195);frame.print("SAT TRACKER");
frame.drawFastHLine(28,234,184,grid);
frame.setTextColor(cyan);frame.setTextSize(1);frame.setCursor(60,249);frame.print("GPS / RF / ORBIT");
frame.setCursor(48,280);frame.print(language==0?"Estacion de radio movil":language==1?"Portable radio station":"Station radio portable");
frame.setCursor(8,307);frame.print("v");frame.print(projectVersion);
frame.flush();
}
}
void setup(){
Serial.begin(115200);
Serial.printf("Firmware v%s\
",projectVersion);
pinMode(32,OUTPUT);digitalWrite(32,LOW);
pinMode(21,OUTPUT);digitalWrite(21,HIGH);
SPI.begin(18,19,23,-1);t.begin(27000000);t.setRotation(0);
ts.begin();digitalWrite(32,HIGH);
store=prefs.begin("hamlog",false);
if(store&&prefs.isKey("uiLang"))language=min(2,int(prefs.getUChar("uiLang")));
if(!store||prefs.getBytesLength("calPortrait")!=sizeof(cal)||prefs.getBytes("calPortrait",&cal,sizeof(cal))!=sizeof(cal)||abs(cal.dx)<800||abs(cal.dy)<800)calibrate();
if(store&&prefs.isKey("qsos")){size_t len=prefs.getBytesLength("qsos");if(len&&len<=sizeof(logs)&&len%sizeof(Contact)==0&&prefs.getBytes("qsos",logs,len)==len)count=len/sizeof(Contact);}
gpsBegin();networkSetup();welcome();welcomeStarted=millis();welcomeActive=true;
}
void loop(){
static bool held=false;static uint32_t last=0;
if(welcomeActive){
gpsTick();
if(millis()-welcomeStarted<3000&&!ts.touched()){vTaskDelay(1);return;}
held=ts.touched();last=millis();welcomeActive=false;draw();
}
if(ts.touched()){
last=millis();
if(!held){held=true;auto p=ts.getPoint();
int x=18+((cal.swap?p.y:p.x)-cal.x0)*203/cal.dx;
int y=18+((cal.swap?p.x:p.y)-cal.y0)*283/cal.dy;
tap(constrain(x,0,239),constrain(y,0,319));
}
}else if(millis()-last>=15)held=false;
gpsTick();networkTick();wifiIcon();vTaskDelay(1);
}
#include "online.h"
void networkSetup(){
if(store)selectedSat=min(int(prefs.getUChar("satpick",0)),satCount-1);
restoreOrbit();
WiFi.persistent(false);
WiFi.mode(WIFI_STA);
WiFi.setAutoReconnect(false);
if(store){
if(prefs.isKey("satgrid"))locator=prefs.getString("satgrid", "");
if(prefs.isKey("ssid"))savedSSID=prefs.getString("ssid");
if(prefs.isKey("wifi"))savedKey=prefs.getString("wifi");
}
NetworkProfile profile{};
if(store&&prefs.isKey("network")&&prefs.getBytes("network",&profile,sizeof(profile))==sizeof(profile)){
profile.ssid[32]=0;profile.key[63]=0;savedSSID=profile.ssid;savedKey=profile.key;
}
if(savedSSID.length())netMessage="Buscando la red guardada...";
}
void networkTick(){
bool dirty=false;uint32_t now=millis();
if(scanning){int n=WiFi.scanComplete();if(n!=WIFI_SCAN_RUNNING){scanning=false;scanState=n;netMessage=n>0?String(n)+" redes encontradas":n==0?"No se encontraron redes":"Error de busqueda";dirty=true;}}
bool up=WiFi.status()==WL_CONNECTED;
if(joining){
if(up&&WiFi.SSID()==netName){joining=false;savedSSID=netName;savedKey=netKey;NetworkProfile profile{};netName.toCharArray(profile.ssid,sizeof(profile.ssid));netKey.toCharArray(profile.key,sizeof(profile.key));bool saved=store&&prefs.putBytes("network",&profile,sizeof(profile))==sizeof(profile);if(saved){prefs.remove("ssid");prefs.remove("wifi");}wifiRetry=now+30000;netKey="";netMessage=saved?"Conexion guardada":"Conectado; no se pudo guardar";dirty=true;}
else if(now-joinAt>=20000){joining=false;WiFi.disconnect();netKey="";wifiRetry=now+5000;netMessage="No conecto. Revisa la clave.";dirty=true;}
}
if(!up&&!joining&&!scanning&&page!=WLAN_KEY&&savedSSID.length()&&(int32_t)(now-wifiRetry)>=0){WiFi.begin(savedSSID.c_str(),savedKey.c_str());wifiRetry=now+30000;}
if(up!=linked){linked=up;dirty=true;if(up){netMessage="Conectado a la red";configTime(0,0,"pool.ntp.org");nextOnline=now;nextOrbit=now;}}
if(orbitTick(now)&&page==SAT)dirty=true;
if(passTick(now)){draw();return;}
if(spotTick(now))dirty=true;
if(solarTick(now))dirty=true;
static String lastGrid;static uint32_t satFrame=0,fullFrame=0;
if(page==HOME&&lastGrid!=gpsGrid()){lastGrid=gpsGrid();dirty=true;}
if((page==SAT||page==GPS_STATUS)&&now-fullFrame>=1000)dirty=true;
if(dirty&&(page==GPS_STATUS||page==DX||page==SOLAR||page==SOTA||page==SAT||page==WLAN||page==HOME||page==TOOLS)){
fullFrame=satFrame=now;draw();
}else if(page==SAT&&satView.ready&&now-satFrame>=125){satFrame=now;draw(true);}
}Remix this project
Make it yours in one click
Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.




