@@ -11,7 +11,11 @@ import {
1111 saveStationConfigAsync ,
1212 selectWiFiAccessPointConfig ,
1313 selectConfig ,
14- selectWiFiStationsConfig
14+ selectWiFiStationsConfig ,
15+ selectPowerSourceType ,
16+ selectStatusLedDuty ,
17+ setStatusLedDutyAsync ,
18+ setPowerSourceTypeAsync
1519} from './configSlice' ;
1620import Spinner from 'react-bootstrap/Spinner' ;
1721import { FaRegEye , FaRegEyeSlash } from "react-icons/fa" ;
@@ -22,6 +26,9 @@ import { ConfirmModal } from '../../ConfirmModal';
2226import { reconnectWiFiAsync } from './appSlice' ;
2327import { RestartModalButton } from './RestartModalButton' ;
2428import { SaveConfigModalButton } from './SaveConfigModalButton' ;
29+ import { Number } from '../Number' ;
30+ import Badge from 'react-bootstrap/Badge' ;
31+ import { setPowerSourceType } from './api' ;
2532
2633const WiFiPasswordControl = ( { label, ...props } ) => {
2734 const [ show , setShow ] = useState ( false ) ;
@@ -105,7 +112,43 @@ const WiFiStations = () => {
105112 </ Form >
106113}
107114
108- export const WiFi = ( ) => {
115+ const AppSettings = ( ) => {
116+ const dispatch = useDispatch ( ) ;
117+ const upstreamPowerSourceType = useSelector ( selectPowerSourceType ) ;
118+ const upstreamLedBrightness = useSelector ( selectStatusLedDuty ) ;
119+
120+ const [ ledBrightness , setLedBrightness ] = useState ( upstreamLedBrightness ) ;
121+ const [ powerSupply , setPowerSupply ] = useState ( upstreamPowerSourceType ) ;
122+ useEffect ( ( ) => {
123+ setLedBrightness ( upstreamLedBrightness ) ;
124+ setPowerSupply ( upstreamPowerSourceType ) ;
125+ } , [ setLedBrightness , setPowerSupply , upstreamLedBrightness , upstreamPowerSourceType ] ) ;
126+
127+ const updateLedBrightness = duty => {
128+ setLedBrightness ( duty )
129+ dispatch ( setStatusLedDutyAsync ( { duty} ) )
130+ }
131+ const updatePowerSourceType = powerSourceType => {
132+ setPowerSupply ( powerSourceType ) ;
133+ dispatch ( setPowerSourceTypeAsync ( { powerSourceType} ) )
134+ }
135+ return < Form >
136+ < Form . Group className = 'mb-3' >
137+ < Form . Label > Status led brightness</ Form . Label >
138+ < Badge className = 'float-end' > < Number value = { ledBrightness * 100 } decimals = { 0 } unit = '%' /> </ Badge >
139+ < Form . Range min = { 0.0 } max = { 1.0 } step = { 0.01 } value = { ledBrightness } onChange = { e => updateLedBrightness ( parseFloat ( e . target . value ) ) } />
140+ </ Form . Group >
141+ < Form . Group className = 'mb-3' >
142+ < Form . Label > Power supply</ Form . Label >
143+ < Form . Select value = { powerSupply } onChange = { e => updatePowerSourceType ( e . target . value ) } >
144+ < option value = "AC" > AC</ option >
145+ < option value = "lipo_3c" > LiPo Battery 3 cells (12v)</ option >
146+ </ Form . Select >
147+ </ Form . Group >
148+ </ Form >
149+ }
150+
151+ export const Config = ( ) => {
109152 const dispatch = useDispatch ( ) ;
110153 useEffect ( ( ) => { dispatch ( getConfigAsync ( ) ) } , [ dispatch ] )
111154 const wifiConfig = useSelector ( selectConfig )
@@ -122,6 +165,9 @@ export const WiFi = () => {
122165 < Row className = 'mt-5' >
123166 < WiFiStations />
124167 </ Row >
168+ < Row className = 'mt-5' >
169+ < AppSettings />
170+ </ Row >
125171 < Row className = 'mt-5' >
126172 < Col sm = { 10 } > Unsaved changes will be lost after restart. Save configuration to flash storage to persist them.</ Col >
127173 < Col sm = { 2 } className = 'd-grid' > < SaveConfigModalButton /> </ Col >
0 commit comments