MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / constructor

Method constructor

contributed/modClock/main.js:162–244  ·  view source on GitHub ↗
(prefs)

Source from the content-addressed store, hash-verified

160
161class Clock {
162 constructor(prefs) {
163 this.prefs = prefs;
164 prefs.owner = this;
165 this.display = new SevenSegDisplay( {
166 length:58, pin:prefs.pin,
167 order:config.seven_segments[prefs.layout].order,
168 tail_on:prefs.tail_on,
169 tail_only:prefs.tail_only,
170 tail_order:prefs.tail_order,
171 tail_sched:prefs.tail_sched,
172 tail_time_on:prefs.tail_time_on,
173 tail_time_off:prefs.tail_time_off,
174 timing:Timing_WS2811,
175 layout:prefs.layout,
176 zero:prefs.zero,
177 tail:prefs.extra,
178 twelve:prefs.twelve,
179 brightness:prefs.brightness,
180 tail_brightness:prefs.tail_brightness } );
181
182 this.styles = [
183 new ClockStyle.OneColor(this.display, {}),
184 new ClockStyle.TwoColor(this.display, {}),
185 new ClockStyle.Rainbow(this.display, {}),
186 new ClockStyle.ColorWheel(this.display, {}),
187 new ClockStyle.Special(this.display, {})
188 ];
189 this.styles.forEach(prefs.loadPref);
190
191 this.currentStyle = this.styles.find(x => x.tag === prefs.style);
192 if (undefined === this.currentStyle)
193 this.currentStyle = this.styles[0];
194 this.styleIdx = 0;
195 this.display.value("helo").blink();
196
197 this.wifiScans = 0;
198 this.connecting = 0;
199 this.usingAP = false;
200
201 this.selectionBarSelected = 0;
202
203 this.setupRtc();
204 if (this.rtc.valid)
205 this.display.showTime(this.currentStyle);
206 else
207 this.display.value("scan").blink();
208
209 if (this.prefs.ssid)
210 this.connect(this.prefs.ssid, this.prefs.pass);
211 else
212 this.configAP(ap_name, AP_PASSWORD);
213
214/*
215 this.monitor = new Monitor({ pin: BUTTON_PIN, mode: Digital.InputPullUp, edge: Monitor.Falling | Monitor.Rising });
216 this.monitor.idx = 0;
217 this.monitor.lastPressed = Time.ticks;
218 this.monitor.timePressed = 0;
219 this.monitor.stillDown = 0;

Callers

nothing calls this directly

Calls 7

setupRtcMethod · 0.95
connectMethod · 0.95
configAPMethod · 0.95
findMethod · 0.80
showTimeMethod · 0.80
blinkMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected