MCPcopy Create free account
hub / github.com/SmingHub/Sming / init

Function init

samples/Basic_HwPWM/app/application.cpp:72–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70} // namespace
71
72void init()
73{
74 Serial.begin(SERIAL_BAUD_RATE); // 115200 by default
75 Serial.systemDebugOutput(true); // Enable debug output to serial
76
77 // WIFI not needed for demo. So disabling WIFI.
78#ifndef DISABLE_WIFI
79 WifiStation.enable(false);
80 WifiAccessPoint.enable(false);
81#endif
82
83 // Change PWM frequency if required: period is in microseconds
84 // pwm.setPeriod(100);
85
86 maxDuty = pwm.getMaxDuty();
87 auto period = pwm.getPeriod();
88 auto freq = pwm.getFrequency(LED_PIN);
89
90 Serial << _F("PWM period = ") << period << _F("us, freq = ") << freq << _F(", max. duty = ") << maxDuty << endl;
91
92 // Set default PWM values
93 for(unsigned i = 0; i < ARRAY_SIZE(pins); ++i) {
94 pwm.analogWrite(pins[i], maxDuty * defaultDutyPercent[i] / 100);
95 }
96
97 Serial << _F("PWM output set on all ") << ARRAY_SIZE(pins) << _F(" Pins. Kindly check...") << endl
98 << _F("Now LED (pin ") << LED_PIN << _F(") will go from 0 to VCC to 0 in cycles.") << endl;
99 procTimer.initializeMs<100>(doPWM).start();
100}

Callers

nothing calls this directly

Calls 8

systemDebugOutputMethod · 0.80
getMaxDutyMethod · 0.80
analogWriteMethod · 0.80
beginMethod · 0.45
enableMethod · 0.45
getPeriodMethod · 0.45
getFrequencyMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected