I developed a portable measurement instrument as a companion to a lab test fixture to get immediate visual feedback on accelerometer data. Using a self-contained display eliminates the need for a laptop at the test site and bypasses the delay of converting text logs to graphs to understand test results.
The "Black Screen" Pitfall
Despite the board's power, getting the integrated 1.14" ST7789 display to initialize is a common hurdle. Unlike simpler modules, this display logic and backlight are gated behind a specific power rail.
The Critical Power Sequence:
- TFT_I2C_POWER: Master gate. Drive HIGH to provide VCC to the display.
- Delay: 10ms settling time for logic stability.
- TFT_BACKLITE: Master backlight enable.
My Use Case: Companion Impact Measurement
Pairing this with a LIS331HH accelerometer (±24G) creates a powerful, compact diagnostic tool. The display handles three primary tasks:
- Dynamic Status: Immediate "Ready" or "Hold" state indication.
- Peak Metrics: Real-time Peak G, Pulse Width (ms), and Rise Time (ms).
- Waveform Visualization: A Z-axis plot to verify impact "shape" instantly.
The S3’s speed and built-in battery management allow for a truly portable instrument. The only external hardware required was a single calibration button to re-zero the gravity vector when changing orientations.
The Initialization Baseline
#include <Arduino.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ST7789.h>
// --- Dark Theme Instrument Palette ---
constexpr uint16_t COL_BG = 0x0000;
constexpr uint16_t COL_LABEL = 0x8410; // Muted gray
constexpr uint16_t COL_PLOT = 0xFD20; // High-vis orange
constexpr uint16_t COL_BLUE = 0x7DFF; // High-contrast sky blue
// Use the pre-defined pin constants from the board support package
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
void initDisplay() {
// STEP 1: Enable the power rail (Mandatory for S3 Feather)
pinMode(TFT_I2C_POWER, OUTPUT);
digitalWrite(TFT_I2C_POWER, HIGH);
delay(10);
// STEP 2: Enable Backlight
pinMode(TFT_BACKLITE, OUTPUT);
digitalWrite(TFT_BACKLITE, HIGH);
// STEP 3: Initialize 135x240 logic
tft.init(135, 240);
// Rotation 3 = Landscape with USB port on the right
tft.setRotation(3);
tft.fillScreen(COL_BG);
}
void drawUI() {
// Label Column
tft.setTextSize(1);
tft.setTextColor(COL_LABEL);
tft.setCursor(8, 28); tft.print("Peak Z [g]");
tft.setCursor(8, 62); tft.print("Width [ms]");
// Data Examples (Using Overprint Erase to prevent flicker)
tft.setTextSize(2);
tft.setTextColor(0xFFE0, COL_BG);
tft.setCursor(8, 38); tft.print("14.8");
// Graph Frame
tft.drawRect(95, 28, 138, 96, 0xC618);
}
void setup() {
initDisplay();
drawUI();
}
void loop() {
// Instrument logic goes here
}
/// EOF
By following this power-on sequence, the S3 Feather becomes a highly capable standalone field instrument, providing instant visual verification where it's needed most—at the test fixture.
Note: This board is available with the display on the top (PID 5483) or the bottom (PID 5493) to accommodate different packaging needs.
No comments:
Post a Comment