TinyMaterialDesign
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
WifiLoginPage< RGB_T > Class Template Reference

WiFi selection and login as a Page: the state of the connection, the SSID with a button that opens the networks of a scan as pop-up list, the password (masked, "Show password"), Connect (Disconnect while connected) and Cancel (leaves the page without connecting). More...

#include <WifiLoginPage.h>

Inheritance diagram for WifiLoginPage< RGB_T >:
Inheritance graph
[legend]
Collaboration diagram for WifiLoginPage< RGB_T >:
Collaboration graph
[legend]

Public Member Functions

 WifiLoginPage (Keyboard< RGB_T > &keyboard, Screen< RGB_T > &screen, const char *title="WiFi")
 
void setWifi (WifiControl *wifi)
 
void setCancelText (const char *text)
 
void connect (const char *ssid, const char *password)
 Fills in the fields and connects (as the Connect button).
 
void startScan ()
 Starts a new scan.
 
void showNetworks ()
 Opens the pop-up list of the networks (as the button next to the SSID).
 
const std::vector< WifiNetwork > & networks () const
 The networks of the last scan.
 
void build () override
 Creates the widgets (called once by PageNavigator::begin()).
 
void onShow () override
 The page becomes visible.
 
void onHide () override
 The page is hidden (another page is shown).
 
bool tick (uint32_t nowMs) override
 Polls the scan and the connection: true if the page changed.
 
- Public Member Functions inherited from Page< RGB_T >
 Page (const char *title="", IconPainter< RGB_T > icon=nullptr)
 
virtual const char * title () const
 Label and icon of the page in a NavigationBar.
 
virtual IconPainter< RGB_T > icon () const
 
void setTitle (const char *title)
 
void setIcon (IconPainter< RGB_T > icon)
 
virtual void build ()
 Creates the widgets (called once by PageNavigator::begin()).
 
virtual void onShow ()
 The page becomes visible.
 
virtual void onHide ()
 The page is hidden (another page is shown).
 
virtual bool tick (uint32_t nowMs)
 
- Public Member Functions inherited from Container< RGB_T >
 Container ()=default
 
 Container (Bounds containerBounds)
 
void addChild (Widget< RGB_T > &child)
 
bool removeChild (Widget< RGB_T > &child)
 
void clearChildren ()
 Removes all children (they are not deleted) and scrolls to the top.
 
int childrenCount () const
 Number of children added with addChild().
 
void setScrollOffset (int32_t offset)
 
void scrollToChild (const Widget< RGB_T > &child, int32_t margin=4)
 
void setChildProvider (ChildCountFn count, ChildAtFn at)
 
void setUniformItemHeight (int32_t height)
 
void setTheme (const MaterialTheme< RGB_T > &theme) override
 
void draw (tinygpu::ISurface< RGB_T > &target) override
 
void drawBackground (tinygpu::ISurface< RGB_T > &target) override
 
bool update (uint32_t nowMs) override
 
bool onGesture (const tinygpu::GestureEvent &event) override
 Handles one gesture event. Returns true if this widget consumed it.
 
int childCount () const override
 
Widget< RGB_T > * child (int index) override
 
int32_t scrollOffset () const
 Current vertical scroll offset (0 = content's natural top).
 
bool isDraggableAt (int32_t x, int32_t y) const override
 
bool isContainer () const override
 Provides true if the widget is a container.
 
- Public Member Functions inherited from Widget< RGB_T >
virtual ~Widget ()=default
 
virtual void setTheme (const MaterialTheme< RGB_T > &theme)
 
virtual void draw (tinygpu::ISurface< RGB_T > &target)=0
 
virtual bool onGesture (const tinygpu::GestureEvent &event)
 Handles one gesture event. Returns true if this widget consumed it.
 
virtual bool update (uint32_t nowMs)
 
virtual bool isDraggable () const
 
virtual bool isDraggableAt (int32_t x, int32_t y) const
 
virtual int childCount () const
 
virtual Widget< RGB_T > * child (int index)
 
virtual void drawBackground (tinygpu::ISurface< RGB_T > &target)
 
virtual void setThemeTint (RGB_T background, RGB_T foreground)
 
virtual bool isContainer () const
 Provides true if the widget is a container.
 

Public Attributes

std::function< void()> onDone
 The user is done: connected or cancelled.
 
- Public Attributes inherited from Widget< RGB_T >
Bounds bounds
 
bool visible = true
 
bool enabled = true
 

Static Public Attributes

static constexpr int kMaxNetworks = 12
 
- Static Public Attributes inherited from Container< RGB_T >
static constexpr int32_t kScrollbarTouchWidth = 12
 

Additional Inherited Members

- Public Types inherited from Container< RGB_T >
using ChildCountFn = std::function< int()>
 
using ChildAtFn = std::function< Widget< RGB_T > &(int index)>
 
- Static Public Member Functions inherited from Container< RGB_T >
static bool isContinuousType (tinygpu::GestureType type)
 
- Protected Member Functions inherited from Container< RGB_T >
int32_t contentHeight () const
 
int32_t scrollThumbHeight (int32_t content) const
 
bool isOnScrollbar (int32_t x, int32_t y) const
 
void scrollToTrackY (int32_t y)
 
void clampScroll ()
 
int effectiveCount () const
 
Widget< RGB_T > * effectiveChild (int index) const
 
- Protected Member Functions inherited from Widget< RGB_T >
const MaterialTheme< RGB_T > & theme () const
 Convenience accessor for draw() overrides - see theme_.
 
- Protected Attributes inherited from Container< RGB_T >
std::vector< Widget< RGB_T > * > children_
 
ChildCountFn childCountFn_
 
ChildAtFn childAtFn_
 
int32_t uniformItemHeight_ = 0
 
Widget< RGB_T > * activeChild_ = nullptr
 
bool scrollDragActive_ = false
 
bool scrollbarDragActive_ = false
 A continuous gesture started on the scrollbar (see isOnScrollbar()).
 
int32_t scrollOffset_ = 0
 
- Protected Attributes inherited from Widget< RGB_T >
const MaterialTheme< RGB_T > * theme_ = nullptr
 

Detailed Description

template<typename RGB_T = TINYMD_DEFAULT_RGB_T>
class tinymd::WifiLoginPage< RGB_T >

WiFi selection and login as a Page: the state of the connection, the SSID with a button that opens the networks of a scan as pop-up list, the password (masked, "Show password"), Connect (Disconnect while connected) and Cancel (leaves the page without connecting).

The WiFi itself is a WifiControl: Esp32Wifi (Wifi/WifiEsp32.h) on the ESP32, SimulatedWifi on the desktop. Show the page on its own, or add it to a PageNavigator; call tick() regularly while it is shown (the PageNavigator does that) - it polls the scan and the connection and returns true when the page must be redrawn.

Keyboard<RGB565> keyboard(Bounds(0, 150, 240, 170)); WifiLoginPage<RGB565> login(keyboard, app.screen()); Esp32Wifi wifi;

void setup() { app.begin(); wifi.begin(); login.setWifi(&wifi); login.bounds = Bounds(0, 40, 240, 280); app.screen().addWidget(login); login.build(); login.onShow(); app.screen().addFixedWidget(keyboard); login.onDone = []() { ... }; // connected or cancelled } void loop() { if (login.tick(millis())) app.screen().invalidate(); app.update(); }

Constructor & Destructor Documentation

◆ WifiLoginPage()

WifiLoginPage ( Keyboard< RGB_T > &  keyboard,
Screen< RGB_T > &  screen,
const char *  title = "WiFi" 
)
inline

Member Function Documentation

◆ build()

void build ( )
inlineoverridevirtual

Creates the widgets (called once by PageNavigator::begin()).

Reimplemented from Page< RGB_T >.

◆ connect()

void connect ( const char *  ssid,
const char *  password 
)
inline

Fills in the fields and connects (as the Connect button).

◆ networks()

const std::vector< WifiNetwork > & networks ( ) const
inline

The networks of the last scan.

◆ onHide()

void onHide ( )
inlineoverridevirtual

The page is hidden (another page is shown).

Reimplemented from Page< RGB_T >.

◆ onShow()

void onShow ( )
inlineoverridevirtual

The page becomes visible.

Reimplemented from Page< RGB_T >.

◆ setCancelText()

void setCancelText ( const char *  text)
inline

Text of the button that leaves the page without connecting (default "Cancel"); nullptr hides it.

◆ setWifi()

void setWifi ( WifiControl *  wifi)
inline

◆ showNetworks()

void showNetworks ( )
inline

Opens the pop-up list of the networks (as the button next to the SSID).

◆ startScan()

void startScan ( )
inline

Starts a new scan.

◆ tick()

bool tick ( uint32_t  nowMs)
inlineoverridevirtual

Polls the scan and the connection: true if the page changed.

Reimplemented from Page< RGB_T >.

Member Data Documentation

◆ kMaxNetworks

constexpr int kMaxNetworks = 12
staticconstexpr

◆ onDone

std::function<void()> onDone

The user is done: connected or cancelled.


The documentation for this class was generated from the following file: