#include "Scanner.h" #include #include extern U8X8_SSD1306_128X64_NONAME_SW_I2C *u8x8; #define CHANBW 10 #define PIXSAMPL (50/CHANBW) #define SMOOTH 4 #define STARTF 400000000 #define NCHAN ((int)(6000/CHANBW)) int scanresult[NCHAN]; int scandisp[NCHAN/PIXSAMPL]; #define PLOT_N 120 #define TICK1 (120/6) #define TICK2 (TICK1/4) #define PLOT_MIN -220 #define PLOT_SCALE(x) (x=8) { row[8*y]=255; continue; } row[8*y] = tilepatterns[nbits]; } } /* * There are 16*8 columns to plot, NPLOT must be lower than that * currently, we use 120 * 50kHz channels * There are 8*8 values to plot; MIN is bottom end, */ uint8_t tiles[16] = { 0x0f,0x0f,0x0f,0x0f,0xf0,0xf0,0xf0,0xf0, 1, 3, 7, 15, 31, 63, 127, 255}; void Scanner::plotResult() { uint8_t row[8*8]; for(int i=0; idrawTile(i/8, y, 1, row+8*y); } } } void Scanner::scan() { #if 0 // Test only for(int i=0; i>16)!=(frf>>16) ) { sx1278.writeRegister(REG_FRF_MSB, (frf&0xff0000)>>16); } if( ((lastfrf&0x00ff00)>>8) != ((frf&0x00ff00)>>8) ) { sx1278.writeRegister(REG_FRF_MID, (frf&0x00ff00)>>8); } sx1278.writeRegister(REG_FRF_LSB, (frf&0x0000ff)); lastfrf = frf; // Wait TS_HOP (20us) + TS_RSSI ( 2^(SMOOTH+1) / 4 / CHANBW us) int wait = 20 + 1000*(1<<(SMOOTH+1))/4/CHANBW; delayMicroseconds(wait); int rssi = -(int)sx1278.readRegister(REG_RSSI_VALUE_FSK); if(iter==0) { scanresult[i] = rssi; } else { if(rssi>scanresult[i]) scanresult[i]=rssi; } } } unsigned long duration = millis()-start; Serial.print("Scan time: "); Serial.println(duration); for(int i=0; iscandisp[i/PIXSAMPL]) scandisp[i/PIXSAMPL] = scanresult[i+j]; } Serial.print(scanresult[i]); Serial.print(", "); } Serial.println("\n"); for(int i=0; i