126 lines
4.3 KiB
C++
126 lines
4.3 KiB
C++
/*
|
|
* "Markers.h" defines the "Marker" class.
|
|
*/
|
|
|
|
#ifndef _MARKERS_H_ // Prevent double include
|
|
#define _MARKERS_H_
|
|
|
|
#include "simpleSA.h" // Definitions needed by the whole program
|
|
|
|
#define MARKER_COUNT 4 // MUST be set to '4' for now
|
|
|
|
#define MARKER_SPRITE_HEIGHT 10 // Reverse of marker width and height
|
|
#define MARKER_SPRITE_WIDTH 7
|
|
#define MARKER_WIDTH 7 // Markers are 7 pixels wide
|
|
#define MARKER_HEIGHT 10 // and 10 pixels high
|
|
#define X_MARKER_OFFSET 3 // Center offset from x position
|
|
#define Y_MARKER_OFFSET MARKER_SPRITE_HEIGHT // Top offset from Y position
|
|
|
|
|
|
/*
|
|
* These definitions are intended to allow the marker to be set to particular
|
|
* places on the spectrum display, but we haven't exactly figured out how to do that
|
|
* yet. For now, marker #1 is always at the highest peak, marker #2 at the 2nd highest
|
|
* peak, etc.
|
|
*/
|
|
|
|
#define MKR_PEAK 1 // Marker is at the maximum signal point
|
|
#define MKR_LEFT 2 // Marker is at first peak left of maximum signal
|
|
#define MKR_RIGHT 3 // Marker is at first peak right of maximum signal
|
|
#define MKR_START 4 // Marker is at sweep start point
|
|
#define MKR_STOP 5 // Marker is at sweep end point
|
|
#define MKR_CENTER 6 // Marker is at the center of the sweep range
|
|
|
|
|
|
/*
|
|
* These definitions are for the bits in the "_status" byte. The "_status" byte
|
|
* contains the enabled status and the color of the marker. It provides a compact
|
|
* way of saving the marker's configuration and restoring the status of the marker
|
|
* when the program is restarted as we do for all the other sweep parameters.
|
|
*/
|
|
|
|
#define MKR_COLOR 0x07 // The bottom three bits hold an index to the color
|
|
#define MKR_ACTIVE 0x08 // Enabled/disabled status
|
|
#define MKR_VISIBLE 0x10 // Not used yet; I'll explain later!
|
|
#define MKR_COLOR_COUNT 6 // Limited by touch screen menu entries
|
|
|
|
|
|
class Marker
|
|
{
|
|
public:
|
|
|
|
/*
|
|
* Function prototypes available to the outside world:
|
|
*
|
|
* There are three constructors; the first simply creates an uninitialized object
|
|
* The second fills in the details by calling one version of the "Init" function.
|
|
* The third one is designed to setup the marker using the "status" byte saved in
|
|
* the flash memory.
|
|
*/
|
|
|
|
explicit Marker (); // Do nothing constructor
|
|
explicit Marker ( TFT_eSprite* spr, uint8_t marker ); // Real constructor #1
|
|
|
|
void Init ( TFT_eSprite* spr, uint8_t marker ); // Psuudo constructor #1
|
|
|
|
void Paint ( TFT_eSprite* target, uint16_t x, uint16_t y ); // Put it on the target sprite
|
|
|
|
void Mode ( uint8_t mode ); // Set marker mode
|
|
uint8_t Mode (); // Request marker's mode
|
|
|
|
void Enable (); // Enable it
|
|
void Enable ( uint8_t mode ); // Enable & set mode all at once
|
|
void Disable (); // Disable it
|
|
void Toggle (); // Toggle enable/disable
|
|
bool isEnabled (); // Request enabled/disabled status
|
|
|
|
uint8_t Status (); // Return the "_status" byte
|
|
void Status ( uint8_t status); // Set the status byte
|
|
|
|
uint16_t Color (); // Returns the merker's color
|
|
bool Color ( uint16_t color ); // Sets the marker's color
|
|
|
|
void Frequency ( uint32_t freq ); // Set the marker's frequency
|
|
uint32_t Frequency (); // Get the frequency
|
|
|
|
uint8_t Index (); // Get marker's index
|
|
|
|
private:
|
|
|
|
TFT_eSprite* _sprite ; // Sprite for the marker
|
|
|
|
uint32_t _frequency; // Marker's frequency
|
|
uint16_t _x; // Horizontal coordinate on the screen
|
|
uint16_t _y; // Vertical coordinate on the screen
|
|
uint16_t _color; // Marker's color
|
|
uint8_t _index; // Which marker?
|
|
uint8_t _mode; // Marker's mode
|
|
byte _status; // Color, enabled and visible all in a byte
|
|
bool _enabled; // Marker is or isn't enabled
|
|
|
|
|
|
/*
|
|
* If we ever figure out how to use different references for the markers,
|
|
* these define the labels for the top of the screen:
|
|
*/
|
|
|
|
const char* _text[6] = { "dBm", "dBc", "uV", "mV", "uW", "mW"};
|
|
|
|
|
|
/*
|
|
* The colors available are limited to the following six. Why six? Because that's the
|
|
* maximum number of touch screen menu selections we can display at once.
|
|
*/
|
|
|
|
|
|
const uint16_t _colors[MKR_COLOR_COUNT] =
|
|
{
|
|
WHITE, RED, BLUE, GREEN, YELLOW, ORANGE
|
|
};
|
|
|
|
uint16_t SwapBytes ( uint16_t color );
|
|
|
|
};
|
|
|
|
#endif
|