diff --git a/README.md b/README.md index 54740fd..da5cecb 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ it with the RSSI value, CRC result and transmitter output power on a nice IPS TFT display. It responds to the transmitter as kind of ack with the RSSI, which is used for some very basic power management in the transmitter, reducing the -supply current from 45 mA down to ~15 mA. The transmitter waits for this +supply current from 50 mA down to 22 mA. The transmitter waits for this response with a timeout so it won't be blocked and consumes a lot of power just because there is no response coming back. diff --git a/avrrfm.c b/avrrfm.c index 46a6894..3bb8a35 100644 --- a/avrrfm.c +++ b/avrrfm.c @@ -33,7 +33,7 @@ #include "dejavu.h" #include "unifont.h" -#define MEASURE_INTS 4 +#define MEASURE_INTS 4 // about 32 seconds #define TIMEOUT_INTS 30 // about one second #define LABEL_OFFSET 10 @@ -217,7 +217,7 @@ snprintf(buf, sizeof (buf), "RSSI: %4d dBm, CRC: %d, PA: %+3d dBm", -_rssi, crc, -18 + (temp->power & 0x1f)); const __flash Font *unifont = &unifontFont; - writeString(0, 0, unifont, buf, WHITE, BLACK); + writeString(0, 0, unifont, buf, BLACK, WHITE); // display temperature (floating, red if CRC failed) snprintf(buf, sizeof (buf), "%c%d.%d°", tempx10 < 0 ? '-' : ' ', @@ -272,6 +272,7 @@ if (RECEIVER) { initDisplay(); setFrame(WHITE); + fillArea(0, 0, DISPLAY_WIDTH, 16, BLACK); // initial rx mode startReceive(); } diff --git a/rfm69.c b/rfm69.c index 637aece..90bbd36 100644 --- a/rfm69.c +++ b/rfm69.c @@ -185,11 +185,8 @@ void setOutputPower(uint8_t rssi) { uint8_t pa = 0x40; // -18 dBm with PA1 - if (rssi > 0 && rssi <= 40) pa += 16; - if (rssi > 40 && rssi <= 60) pa += 21; - if (rssi > 60 && rssi <= 90) pa += 26; - if (rssi > 90) pa += 31; - + // adjust power from -2 to +13 dBm + pa += min(max(rssi - 69, PA_MIN), PA_MAX); regWrite(PA_LEVEL, pa); } diff --git a/rfm69.h b/rfm69.h index 7d8dd31..b9530ef 100644 --- a/rfm69.h +++ b/rfm69.h @@ -73,6 +73,9 @@ #define MODE_TX 0x0c #define MODE_RX 0x10 +#define PA_MIN 16 +#define PA_MAX 31 + #define FIFO_SIZE 64 #define F_STEP 6103515625ULL #define CAST_ADDRESS 0x84