Эх сурвалжийг харах

Пытаюсь получить нормальную картинку. Похоже, что проблема в MAX.

Vladimir N. Shilov 9 жил өмнө
parent
commit
5b27da2da3

+ 4 - 0
.cproject

@@ -27,6 +27,7 @@
 									<listOptionValue builtIn="false" value="&quot;${SMING_HOME}/system/include&quot;"/>
 									<listOptionValue builtIn="false" value="&quot;${SMING_HOME}/system/include&quot;"/>
 									<listOptionValue builtIn="false" value="&quot;${SMING_HOME}/Libraries&quot;"/>
 									<listOptionValue builtIn="false" value="&quot;${SMING_HOME}/Libraries&quot;"/>
 									<listOptionValue builtIn="false" value="&quot;${ESP_HOME}/sdk/include&quot;"/>
 									<listOptionValue builtIn="false" value="&quot;${ESP_HOME}/sdk/include&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MyProj-WallClock/include}&quot;"/>
 								</option>
 								</option>
 								<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.313321806" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
 								<inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.313321806" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
 							</tool>
 							</tool>
@@ -36,6 +37,7 @@
 									<listOptionValue builtIn="false" value="&quot;${SMING_HOME}/system/include&quot;"/>
 									<listOptionValue builtIn="false" value="&quot;${SMING_HOME}/system/include&quot;"/>
 									<listOptionValue builtIn="false" value="&quot;${SMING_HOME}/Libraries&quot;"/>
 									<listOptionValue builtIn="false" value="&quot;${SMING_HOME}/Libraries&quot;"/>
 									<listOptionValue builtIn="false" value="&quot;${ESP_HOME}/sdk/include&quot;"/>
 									<listOptionValue builtIn="false" value="&quot;${ESP_HOME}/sdk/include&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MyProj-WallClock/include}&quot;"/>
 								</option>
 								</option>
 								<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1330530366" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
 								<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1330530366" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
 							</tool>
 							</tool>
@@ -53,6 +55,7 @@
 									<listOptionValue builtIn="false" value="&quot;${SMING_HOME}/system/include&quot;"/>
 									<listOptionValue builtIn="false" value="&quot;${SMING_HOME}/system/include&quot;"/>
 									<listOptionValue builtIn="false" value="&quot;${SMING_HOME}/Libraries&quot;"/>
 									<listOptionValue builtIn="false" value="&quot;${SMING_HOME}/Libraries&quot;"/>
 									<listOptionValue builtIn="false" value="&quot;${ESP_HOME}/sdk/include&quot;"/>
 									<listOptionValue builtIn="false" value="&quot;${ESP_HOME}/sdk/include&quot;"/>
+									<listOptionValue builtIn="false" value="&quot;${workspace_loc:/MyProj-WallClock/include}&quot;"/>
 								</option>
 								</option>
 								<inputType id="cdt.managedbuild.tool.gnu.assembler.input.651581712" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
 								<inputType id="cdt.managedbuild.tool.gnu.assembler.input.651581712" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
 							</tool>
 							</tool>
@@ -61,6 +64,7 @@
 				</configuration>
 				</configuration>
 			</storageModule>
 			</storageModule>
 			<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
 			<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
+			<storageModule moduleId="ilg.gnuarmeclipse.managedbuild.packs"/>
 		</cconfiguration>
 		</cconfiguration>
 	</storageModule>
 	</storageModule>
 	<storageModule moduleId="cdtBuildSystem" version="4.0.0">
 	<storageModule moduleId="cdtBuildSystem" version="4.0.0">

+ 231 - 196
app/application.cpp

@@ -10,7 +10,7 @@
 #include "max7219.h"
 #include "max7219.h"
 #include "webserver.h"
 #include "webserver.h"
 
 
-DHT dht(DHT_PIN, DHT22);
+DHT dht (DHT_PIN, DHT22);
 
 
 Timer procTimer, procRTimer;
 Timer procTimer, procRTimer;
 Timer displayTimer;
 Timer displayTimer;
@@ -21,240 +21,275 @@ String StrCF;
 // Time values
 // Time values
 time_t Time, NTPLastUpdate;
 time_t Time, NTPLastUpdate;
 
 
-void process();
-void connectOk();
-void connectFail();
-void showTime();
+void
+process ();
+void
+connectOk ();
+void
+connectFail ();
+void
+showTime ();
 
 
 // NTP Client
 // NTP Client
-void onNtpReceive(NtpClient& client, time_t timestamp);
+void
+onNtpReceive (NtpClient& client, time_t timestamp);
 NtpClient ntpClient ("ntps1-0.cs.tu-berlin.de", 300, onNtpReceive);
 NtpClient ntpClient ("ntps1-0.cs.tu-berlin.de", 300, onNtpReceive);
 
 
-
-void init()
+void
+init ()
 {
 {
-	spiffs_mount(); // Mount file system, in order to work with files
+  spiffs_mount (); // Mount file system, in order to work with files
 
 
-	Serial.begin(SERIAL_BAUD_RATE); // 115200 by default
-	Serial.systemDebugOutput(false); // Debug output to serial
-	Serial.println("Wall Segment Clock");
+  Serial.begin (SERIAL_BAUD_RATE); // 115200 by default
+  Serial.systemDebugOutput (false); // Debug output to serial
+  Serial.println ("Wall Segment Clock");
 
 
-	ActiveConfig = loadConfig();
+  ActiveConfig = loadConfig ();
 
 
-	//wait for sensor startup
-	delay(1000);
-	// DHT sensor start
-	dht.begin();
+  //wait for sensor startup
+  delay (1000);
+  // DHT sensor start
+  dht.begin ();
 
 
-	// 7-segment output
-	MAX7219_Init();
+  // 7-segment output
+  MAX7219_Init ();
 
 
-	// set timezone hourly difference to UTC
-	SystemClock.setTimeZone(ActiveConfig.AddTZ);
+  // set timezone hourly difference to UTC
+  SystemClock.setTimeZone (ActiveConfig.AddTZ);
 
 
-	WifiStation.config(ActiveConfig.NetworkSSID, ActiveConfig.NetworkPassword);
-	WifiStation.enable(true);
-	WifiAccessPoint.enable(false);
+  WifiStation.config (ActiveConfig.NetworkSSID, ActiveConfig.NetworkPassword);
+  WifiStation.enable (true);
+  WifiAccessPoint.enable (false);
 
 
-	WifiStation.waitConnection(connectOk, 20, connectFail); // We recommend 20+ seconds for connection timeout at start
+  WifiStation.waitConnection (connectOk, 20, connectFail); // We recommend 20+ seconds for connection timeout at start
 
 
-	// раз в минуту?
-	procTimer.initializeMs(60000, process).start();
-	process();
+  // раз в минуту?
+  procTimer.initializeMs (60000, process).start ();
+  process ();
 
 
-	// обновление экрана два раза в секунду
-	displayTimer.initializeMs(500, showTime).start();
+  // обновление экрана два раза в секунду
+  displayTimer.initializeMs (500, showTime).start ();
 }
 }
 
 
-void showTime()
+void
+showTime ()
 {
 {
-	static int8_t oldHour, oldMinute;
-	static time_t oldTime;
-	DateTime dt;
-
-	Time = SystemClock.now();
-
-	dt.setTime(Time);
-
-	/*
-	 * теперь в dt у нас следующее:
-	 * 	int8_t Hour;
-	 * 	int8_t Minute;
-	 * 	int8_t Second;
-	 * 	int16_t Milliseconds;
-	 * 	int8_t Day;
-	 * 	int8_t DayofWeek; -- Sunday is day 0
-	 * 	int8_t Month; // Jan is month 0
-	 * 	int16_t Year;  // Full Year numer
-	 */
-	int8_t si = dt.Second / 5;
-
-	if (oldTime != Time)
-	{
-		oldTime = Time;
-		switch (si)
-		{
-		case 0:
-		case 2:
-		case 4:
-		case 6:
-		case 8:
-		case 10:
-			MAX7219_writeData(MAX7219_DIGIT5, (int)(SensorT)/10);
-			MAX7219_writeData(MAX7219_DIGIT6, (int)(SensorT)%10);
-			MAX7219_writeData(MAX7219_DIGIT7, SYM_Temp);
-			break;
-		case 1:
-		case 3:
-		case 7:
-		case 9:
-			MAX7219_writeData(MAX7219_DIGIT5, (int)(SensorH)/10);
-			MAX7219_writeData(MAX7219_DIGIT6, (int)(SensorH)%10);
-			MAX7219_writeData(MAX7219_DIGIT7, SYM_H);
-			break;
-		case 5:
-		case 11:
-			MAX7219_writeData(MAX7219_DIGIT5, SYM_BLANK);
-			MAX7219_writeData(MAX7219_DIGIT6, dt.DayofWeek/10);
-			MAX7219_writeData(MAX7219_DIGIT7, dt.DayofWeek%10);
-			break;
-		}
-
-		if (oldMinute != dt.Minute)
-		{
-			oldMinute = dt.Minute;
-			if (oldHour != dt.Hour)
-			{
-				oldHour = dt.Hour;
-			}
-		}
-
-		if (si != 5 || si != 11)
-		{
-			MAX7219_writeData(MAX7219_DIGIT0, dt.Hour/10);
-			MAX7219_writeData(MAX7219_DIGIT1, dt.Hour%10);
-			MAX7219_writeData(MAX7219_DIGIT2, SYM_Minus);
-			MAX7219_writeData(MAX7219_DIGIT3, dt.Minute/10);
-			MAX7219_writeData(MAX7219_DIGIT4, dt.Minute%10);
-		}
-		else if (si == 5 || si == 11)
-		{
-			MAX7219_writeData(MAX7219_DIGIT0, dt.Day/10);
-			MAX7219_writeData(MAX7219_DIGIT1, dt.Day%10);
-			MAX7219_writeData(MAX7219_DIGIT2, SYM_Minus);
-			MAX7219_writeData(MAX7219_DIGIT3, dt.Month/10);
-			MAX7219_writeData(MAX7219_DIGIT4, dt.Month%10);
-		}
-
-	}
-	else // time the same, output blank for "hh mm"
-	{
-		if (si != 5 || si != 11)
-		{
-			MAX7219_writeData(MAX7219_DIGIT2, SYM_BLANK);
-		}
-	}
-
+  static int8_t oldHour, oldMinute, pos = 1;
+  static time_t oldTime;
+  DateTime dt;
+
+  Time = SystemClock.now ();
+
+  dt.setTime (Time);
+
+  /*
+   * теперь в dt у нас следующее:
+   * 	int8_t Hour;
+   * 	int8_t Minute;
+   * 	int8_t Second;
+   * 	int16_t Milliseconds;
+   * 	int8_t Day;
+   * 	int8_t DayofWeek; -- Sunday is day 0
+   * 	int8_t Month; // Jan is month 0
+   * 	int16_t Year;  // Full Year numer
+   */
+  int8_t si = dt.Second / 5;
+  if (oldTime != Time)
+    {
+      oldTime = Time;
+
+      if (pos > 8)
+        {
+          pos = 1;
+        }
+      MAX7219_writeData (pos, pos);
+      pos++;
+
+      /*
+       switch (si)
+       {
+       case 0:
+       case 2:
+       case 4:
+       case 6:
+       case 8:
+       case 10:
+       MAX7219_writeData(MAX7219_DIGIT5, (int)(SensorT)/10);
+       MAX7219_writeData(MAX7219_DIGIT6, (int)(SensorT)%10);
+       MAX7219_writeData(MAX7219_DIGIT7, SYM_Temp);
+       break;
+       case 1:
+       case 3:
+       case 7:
+       case 9:
+       MAX7219_writeData(MAX7219_DIGIT5, (int)(SensorH)/10);
+       MAX7219_writeData(MAX7219_DIGIT6, (int)(SensorH)%10);
+       MAX7219_writeData(MAX7219_DIGIT7, SYM_H);
+       break;
+       case 5:
+       case 11:
+       MAX7219_writeData(MAX7219_DIGIT5, SYM_BLANK);
+       MAX7219_writeData(MAX7219_DIGIT6, dt.DayofWeek/10);
+       MAX7219_writeData(MAX7219_DIGIT7, dt.DayofWeek%10);
+       break;
+       }
+       */
+      /*
+       if (oldMinute != dt.Minute)
+       {
+       oldMinute = dt.Minute;
+       if (oldHour != dt.Hour)
+       {
+       oldHour = dt.Hour;
+       }
+       }
+
+       if (si != 5 || si != 11)
+       {
+       MAX7219_writeData(MAX7219_DIGIT0, dt.Hour/10);
+       MAX7219_writeData(MAX7219_DIGIT1, dt.Hour%10);
+       MAX7219_writeData(MAX7219_DIGIT2, SYM_Minus);
+       MAX7219_writeData(MAX7219_DIGIT3, dt.Minute/10);
+       MAX7219_writeData(MAX7219_DIGIT4, dt.Minute%10);
+       }
+       else if (si == 5 || si == 11)
+       {
+       MAX7219_writeData(MAX7219_DIGIT0, dt.Day/10);
+       MAX7219_writeData(MAX7219_DIGIT1, dt.Day%10);
+       MAX7219_writeData(MAX7219_DIGIT2, SYM_Minus);
+       MAX7219_writeData(MAX7219_DIGIT3, dt.Month/10);
+       MAX7219_writeData(MAX7219_DIGIT4, dt.Month%10);
+       }
+       */
+      /*
+       if ((si & 1) == 0)
+       {
+       MAX7219_writeData(MAX7219_DIGIT5, (int)(SensorT)/10);
+       MAX7219_writeData(MAX7219_DIGIT6, (int)(SensorT)%10);
+       MAX7219_writeData(MAX7219_DIGIT7, SYM_Temp);
+       }
+       else
+       {
+       MAX7219_writeData(MAX7219_DIGIT5, (int)(SensorH)/10);
+       MAX7219_writeData(MAX7219_DIGIT6, (int)(SensorH)%10);
+       MAX7219_writeData(MAX7219_DIGIT7, SYM_H);
+       }
+       */
+    }
+  /*
+   else // time the same, output blank for "hh mm"
+   {
+   if (si != 5 || si != 11)
+   {
+   MAX7219_writeData(MAX7219_DIGIT2, SYM_BLANK	);
+   }
+   }
+   */
 }
 }
 
 
 /*
 /*
  * Читаем данные с DHT22, в случае неудачи -- данные остануться старыми.
  * Читаем данные с DHT22, в случае неудачи -- данные остануться старыми.
  * меня это полностью устраивает.
  * меня это полностью устраивает.
  */
  */
-void process()
+void
+process ()
 {
 {
-	TempAndHumidity th;
-	ComfortState cf;
-	static int8_t status;
-
-	if(dht.readTempAndHumidity(th))
-	{
-		status = 0;
-		SensorT = th.temp;
-		SensorH = th.humid;
-		SensorHI = dht.getHeatIndex();
-		SensorCR = dht.getComfortRatio(cf);
-
-		switch(cf)
-		{
-		case Comfort_OK:
-			StrCF = "OK";
-			break;
-		case Comfort_TooHot:
-			StrCF = "Too Hot";
-			break;
-		case Comfort_TooCold:
-			StrCF = "Too Cold";
-			break;
-		case Comfort_TooDry:
-			StrCF = "Too Dry";
-			break;
-		case Comfort_TooHumid:
-			StrCF = "Too Humid";
-			break;
-		case Comfort_HotAndHumid:
-			StrCF = "Hot And Humid";
-			break;
-		case Comfort_HotAndDry:
-			StrCF = "Hot And Dry";
-			break;
-		case Comfort_ColdAndHumid:
-			StrCF = "Cold And Humid";
-			break;
-		case Comfort_ColdAndDry:
-			StrCF = "Cold And Dry";
-			break;
-		default:
-			StrCF = "Unknown";
-			break;
-		}
-	}
-	else
-	{
-		/*
-		 * В случае, если от датчика ничего не получили, запустим повторный опрос через
-		 * 10 секунд, но не более 5 раз подряд.
-		 */
-		if (status < 6)
-		{
-			status ++;
-			procRTimer.initializeMs(10000, process).startOnce();
-		}
-	}
+  TempAndHumidity th;
+  ComfortState cf;
+  static int8_t status;
+
+  if (dht.readTempAndHumidity (th))
+    {
+      status = 0;
+      SensorT = th.temp;
+      SensorH = th.humid;
+      SensorHI = dht.getHeatIndex ();
+      SensorCR = dht.getComfortRatio (cf);
+
+      switch (cf)
+        {
+        case Comfort_OK:
+          StrCF = "OK";
+          break;
+        case Comfort_TooHot:
+          StrCF = "Too Hot";
+          break;
+        case Comfort_TooCold:
+          StrCF = "Too Cold";
+          break;
+        case Comfort_TooDry:
+          StrCF = "Too Dry";
+          break;
+        case Comfort_TooHumid:
+          StrCF = "Too Humid";
+          break;
+        case Comfort_HotAndHumid:
+          StrCF = "Hot And Humid";
+          break;
+        case Comfort_HotAndDry:
+          StrCF = "Hot And Dry";
+          break;
+        case Comfort_ColdAndHumid:
+          StrCF = "Cold And Humid";
+          break;
+        case Comfort_ColdAndDry:
+          StrCF = "Cold And Dry";
+          break;
+        default:
+          StrCF = "Unknown";
+          break;
+        }
+    }
+  else
+    {
+      /*
+       * В случае, если от датчика ничего не получили, запустим повторный опрос через
+       * 10 секунд, но не более 5 раз подряд.
+       */
+      if (status < 6)
+        {
+          status++;
+          procRTimer.initializeMs (10000, process).startOnce ();
+        }
+    }
 }
 }
 
 
-void connectOk()
+void
+connectOk ()
 {
 {
-	WifiAccessPoint.enable(false);
-	Serial.print("I'm connecteed. IP: ");
-	Serial.println(WifiStation.getIP().toString());
+  WifiAccessPoint.enable (false);
+  Serial.print ("I'm connecteed. IP: ");
+  Serial.println (WifiStation.getIP ().toString ());
 
 
-	startWebServer();
+  startWebServer ();
 }
 }
 
 
 /*
 /*
  * в случае неудачи подключения поднимаем точку доступа без авторизации
  * в случае неудачи подключения поднимаем точку доступа без авторизации
  */
  */
-void connectFail()
+void
+connectFail ()
 {
 {
-	WifiAccessPoint.config("MeteoConfig", "", AUTH_OPEN);
-	WifiAccessPoint.enable(true);
-	// Stop main screen output
-	procTimer.stop();
-	displayTimer.stop();
+  WifiAccessPoint.config ("MeteoConfig", "", AUTH_OPEN);
+  WifiAccessPoint.enable (true);
+  // Stop main screen output
+  procTimer.stop ();
+  displayTimer.stop ();
 
 
-	Serial.println("WiFi MeteoConfig");
-	Serial.println(WifiAccessPoint.getIP());
+  Serial.println ("WiFi MeteoConfig");
+  Serial.println (WifiAccessPoint.getIP ());
 
 
-	startWebServer();
-	WifiStation.waitConnection(connectOk); // Wait connection
+  startWebServer ();
+  WifiStation.waitConnection (connectOk); // Wait connection
 }
 }
 
 
 /*
 /*
  * NTP Client
  * NTP Client
  */
  */
-void onNtpReceive(NtpClient& client, time_t timestamp) {
-	SystemClock.setTime(timestamp, eTZ_UTC);
-	NTPLastUpdate = SystemClock.now();
-	Serial.println("*** Time synchronized OK! ***"); // DEBUG
+void
+onNtpReceive (NtpClient& client, time_t timestamp)
+{
+  SystemClock.setTime (timestamp, eTZ_UTC);
+  NTPLastUpdate = SystemClock.now ();
+  Serial.println ("*** Time synchronized OK! ***"); // DEBUG
 }
 }

+ 65 - 64
app/configuration.cpp

@@ -4,73 +4,74 @@
 
 
 ClockConfig ActiveConfig;
 ClockConfig ActiveConfig;
 
 
-ClockConfig loadConfig()
+ClockConfig
+loadConfig ()
 {
 {
-	DynamicJsonBuffer jsonBuffer;
-	ClockConfig cfg;
-	if (fileExist(CLOCK_CONFIG_FILE))
-	{
-		int size = fileGetSize(CLOCK_CONFIG_FILE);
-		char* jsonString = new char[size + 1];
-		fileGetContent(CLOCK_CONFIG_FILE, jsonString, size + 1);
-		JsonObject& root = jsonBuffer.parseObject(jsonString);
-
-		JsonObject& network = root["network"];
-		cfg.NetworkSSID = String((const char*)network["ssid"]);
-		cfg.NetworkPassword = String((const char*)network["password"]);
-
-		JsonObject& correction = root["correction"];
-		cfg.AddTZ = correction["TZ"];
-
-		JsonObject& light = root["light"];
-		cfg.LightTrhLow = light["low"];
-		cfg.LightTrhHigh = light["high"];
-
-		JsonObject& bright = root["bright"];
-		cfg.BrightnessLow = bright["low"];
-		cfg.BrightnessMiddle = bright["mid"];
-		cfg.BrightnessHigh = bright["high"];
-
-		delete[] jsonString;
-	}
-	else
-	{
-		cfg.NetworkSSID = WIFI_SSID;
-		cfg.NetworkPassword = WIFI_PWD;
-	}
-	return cfg;
+  DynamicJsonBuffer jsonBuffer;
+  ClockConfig cfg;
+  if (fileExist (CLOCK_CONFIG_FILE))
+    {
+      int size = fileGetSize (CLOCK_CONFIG_FILE);
+      char* jsonString = new char[size + 1];
+      fileGetContent (CLOCK_CONFIG_FILE, jsonString, size + 1);
+      JsonObject& root = jsonBuffer.parseObject (jsonString);
+
+      JsonObject& network = root["network"];
+      cfg.NetworkSSID = String ((const char*) network["ssid"]);
+      cfg.NetworkPassword = String ((const char*) network["password"]);
+
+      JsonObject& correction = root["correction"];
+      cfg.AddTZ = correction["TZ"];
+
+      JsonObject& light = root["light"];
+      cfg.LightTrhLow = light["low"];
+      cfg.LightTrhHigh = light["high"];
+
+      JsonObject& bright = root["bright"];
+      cfg.BrightnessLow = bright["low"];
+      cfg.BrightnessMiddle = bright["mid"];
+      cfg.BrightnessHigh = bright["high"];
+
+      delete[] jsonString;
+    }
+  else
+    {
+      cfg.NetworkSSID = WIFI_SSID;
+      cfg.NetworkPassword = WIFI_PWD;
+    }
+  return cfg;
 }
 }
 
 
-void saveConfig(ClockConfig& cfg)
+void
+saveConfig (ClockConfig& cfg)
 {
 {
-	ActiveConfig = cfg;
-
-	DynamicJsonBuffer jsonBuffer;
-	JsonObject& root = jsonBuffer.createObject();
-
-	JsonObject& network = jsonBuffer.createObject();
-	root["network"] = network;
-	network["ssid"] = cfg.NetworkSSID.c_str();
-	network["password"] = cfg.NetworkPassword.c_str();
-
-	JsonObject& correction = jsonBuffer.createObject();
-	root["correction"] = correction;
-	correction["TZ"] = cfg.AddTZ;
-
-	JsonObject& light = jsonBuffer.createObject();
-	root["light"] = light;
-	light["low"] = cfg.LightTrhLow;
-	light["high"] = cfg.LightTrhHigh;
-
-	JsonObject& bright = jsonBuffer.createObject();
-	root["bright"] = bright;
-	bright["low"] = cfg.BrightnessLow;
-	bright["mid"] = cfg.BrightnessMiddle;
-	bright["high"] = cfg.BrightnessHigh;
-
-	char buf[3048];
-	root.prettyPrintTo(buf, sizeof(buf));
-	fileSetContent(CLOCK_CONFIG_FILE, buf);
+  ActiveConfig = cfg;
+
+  DynamicJsonBuffer jsonBuffer;
+  JsonObject& root = jsonBuffer.createObject ();
+
+  JsonObject& network = jsonBuffer.createObject ();
+  root["network"] = network;
+  network["ssid"] = cfg.NetworkSSID.c_str ();
+  network["password"] = cfg.NetworkPassword.c_str ();
+
+  JsonObject& correction = jsonBuffer.createObject ();
+  root["correction"] = correction;
+  correction["TZ"] = cfg.AddTZ;
+
+  JsonObject& light = jsonBuffer.createObject ();
+  root["light"] = light;
+  light["low"] = cfg.LightTrhLow;
+  light["high"] = cfg.LightTrhHigh;
+
+  JsonObject& bright = jsonBuffer.createObject ();
+  root["bright"] = bright;
+  bright["low"] = cfg.BrightnessLow;
+  bright["mid"] = cfg.BrightnessMiddle;
+  bright["high"] = cfg.BrightnessHigh;
+
+  char buf[3048];
+  root.prettyPrintTo (buf, sizeof(buf));
+  fileSetContent (CLOCK_CONFIG_FILE, buf);
 }
 }
 
 
-

+ 40 - 66
app/max7219.cpp

@@ -13,80 +13,54 @@
 #include "configuration.h"
 #include "configuration.h"
 #include "max7219.h"
 #include "max7219.h"
 
 
-#define MAX7219_ON				0x01
-#define MAX7219_OFF				0x00
-#define MAX7219_BRIGHT			0x08
-
 // перевод числа 0-7 в номер индикатора
 // перевод числа 0-7 в номер индикатора
-const uint8_t max7219_dig[8] = {
-	0x05,0x01,0x07,0x03,0x04,0x08,0x06,0x02
-};
-
-// программный SPI. Выводит байт начиная со старшего бита
-// выходные пины -- SCK, MOSI
-static void spi_SendByte (uint8_t DataByte) {
-	uint8_t i; // счетчик бит
+//const uint8_t max7219_dig[8] = {
+//	0x05,0x01,0x07,0x03,0x04,0x08,0x06,0x02
+//};
 
 
-	for (i=8; i!=0; i--) {
-		PinRes(PIN_CLK); // выдали строб
-		if (bit_is_set(DataByte,7)) { // если бит 7 == 1
-			PinSet(PIN_DIN); // MOSI = 1
-		} else { // если бит 7 == 0
-			PinRes(PIN_DIN); // MOSI = 0
-		}
-		PinSet(PIN_CLK); // защёлкнули строб
-		DataByte <<= 1; // сдвиг влево на 1 бит
-	}
-
-}
-
-void MAX7219_writeData(uint8_t reg, uint8_t data)
+void
+MAX7219_writeData (uint8_t reg, uint8_t data)
 {
 {
-//    PinRes(PIN_LOAD); // опустили защёлку
-	digitalWrite(PIN_LOAD, LOW);
+  PinRes(PIN_LOAD); // опустили защёлку
 
 
-//    spi_SendByte(reg);
-//    spi_SendByte(data);
+  // software spi
+  uint8_t i; // счетчик бит
+  uint16_t sdata = ((reg & 0x000F) << 8) | (data & 0x00FF);
+  for (i = 16; i != 0; i--)
+    {
+      PinRes(PIN_CLK); // выдали строб
+      if (sdata >= 0x8000)
+        { // если старший бит == 1
+          PinSet(PIN_DIN); // MOSI = 1
+        }
+      else
+        { // если старший бит == 0
+          PinRes(PIN_DIN); // MOSI = 0
+        }
+      PinSet(PIN_CLK); // защёлкнули строб
 
 
-    // software spi
-	uint8_t i; // счетчик бит
-	uint16_t sdata = (reg<<8) || data;
-	for (i=16; i!=0; i--) {
-//		PinRes(PIN_CLK); // выдали строб
-		digitalWrite(PIN_CLK, LOW);
-		if (bit_is_set(sdata,15)) { // если старший бит == 1
-//			PinSet(PIN_DIN); // MOSI = 1
-			digitalWrite(PIN_DIN, HIGH);
-		} else { // если старший бит == 0
-//			PinRes(PIN_DIN); // MOSI = 0
-			digitalWrite(PIN_DIN, LOW);
-		}
-//		PinSet(PIN_CLK); // защёлкнули строб
-		digitalWrite(PIN_CLK, HIGH);
+      sdata <<= 1; // сдвиг влево на 1 бит
+    }
 
 
-		sdata <<= 1; // сдвиг влево на 1 бит
-	}
+  PinSet(PIN_LOAD); // подняли защёлку
 
 
-//    PinSet(PIN_LOAD); // подняли защёлку
-	digitalWrite(PIN_LOAD, HIGH);
+  PinSet(PIN_DIN);
 }
 }
 
 
-void MAX7219_Init(void) {
-// настройка пинов SPI
-	pinMode(PIN_LOAD, OUTPUT);
-	pinMode(PIN_DIN, OUTPUT);
-	pinMode(PIN_CLK, OUTPUT);
-//	PinSet(PIN_LOAD);
-//	PinSet(PIN_DIN);
-//	PinSet(PIN_CLK);
-	digitalWrite(PIN_LOAD, HIGH);
-	digitalWrite(PIN_DIN, HIGH);
-	digitalWrite(PIN_CLK, HIGH);
-
-//	Настройка MAX71219
-	MAX7219_writeData(MAX7219_MODE_DECODE, 0x7B); // без BCD декодирования 2 и 7
-	MAX7219_writeData(MAX7219_MODE_SCAN_LIMIT, MAX7219_DIGITS - 1); // Scan limit runs from 0.
-	MAX7219_writeData(MAX7219_MODE_INTENSITY, MAX7219_BRIGHT); // яркость: от 1 до 31 с шагом в 2
-	MAX7219_writeData(MAX7219_MODE_POWER,MAX7219_ON); // включили питание
+void
+MAX7219_Init (void)
+{
+  // настройка пинов SPI
+  pinMode (PIN_LOAD, OUTPUT);
+  pinMode (PIN_DIN, OUTPUT);
+  pinMode (PIN_CLK, OUTPUT);
+  PinSet(PIN_LOAD);
+  PinSet(PIN_DIN);
+  PinSet(PIN_CLK);
 
 
+  // Настройка MAX71219
+  MAX7219_writeData (MAX7219_MODE_DECODE, 0xFF); //0x7B); // без BCD декодирования 2, 7
+  MAX7219_writeData (MAX7219_MODE_SCAN_LIMIT, MAX7219_DIGITS - 1); // Scan limit runs from 0.
+  MAX7219_writeData (MAX7219_MODE_INTENSITY, MAX7219_BRIGHT); // яркость
+  MAX7219_writeData (MAX7219_MODE_POWER, MAX7219_ON); // включили питание
 }
 }

+ 171 - 156
app/webserver.cpp

@@ -15,195 +15,210 @@ extern time_t NTPLastUpdate;
  * Index page.
  * Index page.
  * Show dht22 data as integer.
  * Show dht22 data as integer.
  */
  */
-void onIndex(HttpRequest &request, HttpResponse &response)
+void
+onIndex (HttpRequest &request, HttpResponse &response)
 {
 {
-	TemplateFileStream *tmpl = new TemplateFileStream("index.html");
-	auto &vars = tmpl->variables();
-	vars["T"] = String(SensorT, 0);
-	vars["RH"] = String(SensorH, 0);
-	vars["HI"] = String(SensorHI, 0);
-	vars["CR"] = String(SensorCR, 0);
-	vars["CF"] = StrCF; // это первое место, где оно используется
-	vars["ADC"] = String(system_adc_read());
-	vars["VDD"] = String(system_get_vdd33());
-	vars["LASTNTP"] = String(SystemClock.now() - NTPLastUpdate);
-	response.sendTemplate(tmpl);
+  TemplateFileStream *tmpl = new TemplateFileStream ("index.html");
+  auto &vars = tmpl->variables ();
+  vars["T"] = String (SensorT, 0);
+  vars["RH"] = String (SensorH, 0);
+  vars["HI"] = String (SensorHI, 0);
+  vars["CR"] = String (SensorCR, 0);
+  vars["CF"] = StrCF; // это первое место, где оно используется
+  vars["ADC"] = String (system_adc_read ());
+  vars["VDD"] = String (system_get_vdd33 ());
+  vars["LASTNTP"] = String (SystemClock.now () - NTPLastUpdate);
+  response.sendTemplate (tmpl);
 }
 }
 
 
 /*
 /*
  * Configuration page.
  * Configuration page.
  */
  */
-void onConfiguration(HttpRequest &request, HttpResponse &response)
+void
+onConfiguration (HttpRequest &request, HttpResponse &response)
 {
 {
-	ClockConfig cfg = loadConfig();
-	if (request.getRequestMethod() == RequestMethod::POST)
-	{
-		// Update config
-		if (request.getPostParameter("SSID").length() > 0) // Network
-		{
-			cfg.NetworkSSID = request.getPostParameter("SSID");
-			cfg.NetworkPassword = request.getPostParameter("Password");
-		}
-
-		if (request.getPostParameter("TZ").length() > 0) // Correction
-		{
-			float tz = request.getPostParameter("TZ").toFloat();
-			if (cfg.AddTZ != tz)
-			{
-				cfg.AddTZ = tz;
-				SystemClock.setTimeZone(cfg.AddTZ);
-				if (cfg.AddTZ<0 || cfg.AddTZ>23)
-				{
-					cfg.AddTZ = 0;
-				}
-			}
-		}
-
-		if (request.getPostParameter("BLow").length() > 0) // Low brightness level.
-		{
-			cfg.BrightnessLow = request.getPostParameter("BLow").toInt();
-			if (cfg.BrightnessLow<0 || cfg.BrightnessLow>15)
-			{
-				cfg.BrightnessLow = 0;
-			}
-		}
-		if (request.getPostParameter("BMid").length() > 0) // Middle brightness level.
-		{
-			cfg.BrightnessMiddle = request.getPostParameter("BMid").toInt();
-			if (cfg.BrightnessMiddle<0 || cfg.BrightnessMiddle>15)
-			{
-				cfg.BrightnessMiddle = 7;
-			}
-		}
-		if (request.getPostParameter("BHigh").length() > 0) // High brightness level.
-		{
-			cfg.BrightnessHigh = request.getPostParameter("BHigh").toInt();
-			if (cfg.BrightnessHigh<0 || cfg.BrightnessHigh>15)
-			{
-				cfg.BrightnessHigh = 15;
-			}
-		}
-
-		if (request.getPostParameter("LLow").length() > 0) // Low light level trh.
-		{
-			cfg.LightTrhLow = request.getPostParameter("LLow").toInt();
-			if (cfg.LightTrhLow<0 || cfg.LightTrhLow>1023)
-			{
-				cfg.LightTrhLow = 0;
-			}
-		}
-		if (request.getPostParameter("LHigh").length() > 0) // High light level trh.
-		{
-			cfg.LightTrhHigh = request.getPostParameter("LHigh").toInt();
-			if (cfg.LightTrhHigh<0 || cfg.LightTrhHigh>1023)
-			{
-				cfg.LightTrhHigh = 1023;
-			}
-		}
-		saveConfig(cfg);
-		response.redirect();
-	}
-
-	TemplateFileStream *tmpl = new TemplateFileStream("config.html");
-	auto &vars = tmpl->variables();
-	vars["SSID"] = cfg.NetworkSSID;
-	vars["TZ"] = String(cfg.AddTZ, 2);
-	vars["LLow"] = String(cfg.LightTrhLow);
-	vars["LHigh"] = String(cfg.LightTrhHigh);
-	vars["BLow"] = String(cfg.BrightnessLow);
-	vars["BMid"] = String(cfg.BrightnessMiddle);
-	vars["BHigh"] = String(cfg.BrightnessHigh);
-	response.sendTemplate(tmpl);
+  ClockConfig cfg = loadConfig ();
+  if (request.getRequestMethod () == RequestMethod::POST)
+    {
+      // Update config
+      if (request.getPostParameter ("SSID").length () > 0) // Network
+        {
+          cfg.NetworkSSID = request.getPostParameter ("SSID");
+          cfg.NetworkPassword = request.getPostParameter ("Password");
+        }
+
+      if (request.getPostParameter ("TZ").length () > 0) // Correction
+        {
+          float tz = request.getPostParameter ("TZ").toFloat ();
+          if (cfg.AddTZ != tz)
+            {
+              cfg.AddTZ = tz;
+              SystemClock.setTimeZone (cfg.AddTZ);
+              if (cfg.AddTZ < 0 || cfg.AddTZ > 23)
+                {
+                  cfg.AddTZ = 0;
+                }
+            }
+        }
+
+      if (request.getPostParameter ("BLow").length () > 0) // Low brightness level.
+        {
+          cfg.BrightnessLow = request.getPostParameter ("BLow").toInt ();
+          if (cfg.BrightnessLow < 0 || cfg.BrightnessLow > 15)
+            {
+              cfg.BrightnessLow = 0;
+            }
+        }
+      if (request.getPostParameter ("BMid").length () > 0) // Middle brightness level.
+        {
+          cfg.BrightnessMiddle = request.getPostParameter ("BMid").toInt ();
+          if (cfg.BrightnessMiddle < 0 || cfg.BrightnessMiddle > 15)
+            {
+              cfg.BrightnessMiddle = 7;
+            }
+        }
+      if (request.getPostParameter ("BHigh").length () > 0) // High brightness level.
+        {
+          cfg.BrightnessHigh = request.getPostParameter ("BHigh").toInt ();
+          if (cfg.BrightnessHigh < 0 || cfg.BrightnessHigh > 15)
+            {
+              cfg.BrightnessHigh = 15;
+            }
+        }
+
+      if (request.getPostParameter ("LLow").length () > 0) // Low light level trh.
+        {
+          cfg.LightTrhLow = request.getPostParameter ("LLow").toInt ();
+          if (cfg.LightTrhLow < 0 || cfg.LightTrhLow > 1023)
+            {
+              cfg.LightTrhLow = 0;
+            }
+        }
+      if (request.getPostParameter ("LHigh").length () > 0) // High light level trh.
+        {
+          cfg.LightTrhHigh = request.getPostParameter ("LHigh").toInt ();
+          if (cfg.LightTrhHigh < 0 || cfg.LightTrhHigh > 1023)
+            {
+              cfg.LightTrhHigh = 1023;
+            }
+        }
+      saveConfig (cfg);
+      response.redirect ();
+    }
+
+  TemplateFileStream *tmpl = new TemplateFileStream ("config.html");
+  auto &vars = tmpl->variables ();
+  vars["SSID"] = cfg.NetworkSSID;
+  vars["TZ"] = String (cfg.AddTZ, 2);
+  vars["LLow"] = String (cfg.LightTrhLow);
+  vars["LHigh"] = String (cfg.LightTrhHigh);
+  vars["BLow"] = String (cfg.BrightnessLow);
+  vars["BMid"] = String (cfg.BrightnessMiddle);
+  vars["BHigh"] = String (cfg.BrightnessHigh);
+  response.sendTemplate (tmpl);
 }
 }
 
 
 /*
 /*
  * роутер
  * роутер
  */
  */
-void onFile(HttpRequest &request, HttpResponse &response)
+void
+onFile (HttpRequest &request, HttpResponse &response)
 {
 {
-	String file = request.getPath();
-	if (file[0] == '/')
-		file = file.substring(1);
-
-	if (file[0] == '.')
-		response.forbidden();
-	else
-	{
-		response.setCache(86400, true); // It's important to use cache for better performance.
-		response.sendFile(file);
-	}
+  String file = request.getPath ();
+  if (file[0] == '/')
+    file = file.substring (1);
+
+  if (file[0] == '.')
+    response.forbidden ();
+  else
+    {
+      response.setCache (86400, true); // It's important to use cache for better performance.
+      response.sendFile (file);
+    }
 }
 }
 
 
 /// API ///
 /// API ///
 /*
 /*
  * API page.
  * API page.
  */
  */
-void onApiDoc(HttpRequest &request, HttpResponse &response)
+void
+onApiDoc (HttpRequest &request, HttpResponse &response)
 {
 {
-	TemplateFileStream *tmpl = new TemplateFileStream("api.html");
-	auto &vars = tmpl->variables();
-	vars["IP"] = (WifiStation.isConnected() ? WifiStation.getIP() : WifiAccessPoint.getIP()).toString();
-	response.sendTemplate(tmpl);
+  TemplateFileStream *tmpl = new TemplateFileStream ("api.html");
+  auto &vars = tmpl->variables ();
+  vars["IP"] = (
+      WifiStation.isConnected () ?
+          WifiStation.getIP () : WifiAccessPoint.getIP ()).toString ();
+  response.sendTemplate (tmpl);
 }
 }
 
 
 /*
 /*
  * Get json data
  * Get json data
  * данные с датчиков выдаём с максимальным разрешением.
  * данные с датчиков выдаём с максимальным разрешением.
  */
  */
-void onApiSensors(HttpRequest &request, HttpResponse &response)
+void
+onApiSensors (HttpRequest &request, HttpResponse &response)
 {
 {
-	JsonObjectStream* stream = new JsonObjectStream();
-	JsonObject& json = stream->getRoot();
-	json["status"] = (bool)true;
-	JsonObject& sensors = json.createNestedObject("sensors");
-	sensors["temperature"] = String(SensorT, 2);
-	sensors["humidity"] = String(SensorH, 2);
-	sensors["heatindex"] = String(SensorHI, 2);
-	sensors["comfortp"] = String(SensorCR, 2);
-	sensors["comforts"] = StrCF.c_str(); // второе место
-	sensors["adcvalue"] = String(system_adc_read());
-	sensors["vddvalue"] = String(system_get_vdd33());
-	time_t now = SystemClock.now();
-	sensors["datetime"] = String(now);
-	sensors["lastntp"] = String(now - NTPLastUpdate);
-	response.sendJsonObject(stream);
+  JsonObjectStream* stream = new JsonObjectStream ();
+  JsonObject& json = stream->getRoot ();
+  json["status"] = (bool) true;
+  JsonObject& sensors = json.createNestedObject ("sensors");
+  sensors["temperature"] = String (SensorT, 2);
+  sensors["humidity"] = String (SensorH, 2);
+  sensors["heatindex"] = String (SensorHI, 2);
+  sensors["comfortp"] = String (SensorCR, 2);
+  sensors["comforts"] = StrCF.c_str (); // второе место
+  sensors["adcvalue"] = String (system_adc_read ());
+  sensors["vddvalue"] = String (system_get_vdd33 ());
+  time_t now = SystemClock.now ();
+  sensors["datetime"] = String (now);
+  sensors["lastntp"] = String (now - NTPLastUpdate);
+  response.sendJsonObject (stream);
 }
 }
 
 
 /*
 /*
  * Управление выводом. кандидат на удаление.
  * Управление выводом. кандидат на удаление.
  */
  */
-/*
-void onApiOutput(HttpRequest &request, HttpResponse &response)
+#include "max7219.h"
+void
+onApiControl (HttpRequest &request, HttpResponse &response)
 {
 {
-	int val = request.getQueryParameter("control", "-1").toInt();
-	if (val == 0 || val == 1)
-		digitalWrite(CONTROL_PIN, val == 1);
-	else
-		val = -1;
-
-	JsonObjectStream* stream = new JsonObjectStream();
-	JsonObject& json = stream->getRoot();
-	json["status"] = val != -1;
-	if (val == -1) json["error"] = "Wrong control parameter value, please use: ?control=0|1";
-	response.sendJsonObject(stream);
+  int val = request.getQueryParameter ("bright", "-1").toInt ();
+  if (val < 1)
+    {
+      val = 1;
+    }
+  if (val > 15)
+    {
+      val = 15;
+    }
+
+  MAX7219_writeData (MAX7219_MODE_INTENSITY, val);
+
+  JsonObjectStream* stream = new JsonObjectStream ();
+  JsonObject& json = stream->getRoot ();
+  json["status"] = val;
+  response.sendJsonObject (stream);
 }
 }
-*/
-void startWebServer()
+
+void
+startWebServer ()
 {
 {
-	if (serverStarted) return;
-
-	server.listen(80);
-	server.addPath("/", onIndex);
-	server.addPath("/api", onApiDoc);
-	server.addPath("/api/sensors", onApiSensors);
-//	server.addPath("/api/output", onApiOutput);
-	server.addPath("/config", onConfiguration);
-	server.setDefaultHandler(onFile);
-	serverStarted = true;
-/*
-	if (WifiStation.isEnabled())
-		debugf("STA: %s", WifiStation.getIP().toString().c_str());
-	if (WifiAccessPoint.isEnabled())
-		debugf("AP: %s", WifiAccessPoint.getIP().toString().c_str());
-*/
+  if (serverStarted)
+    return;
+
+  server.listen (80);
+  server.addPath ("/", onIndex);
+  server.addPath ("/api", onApiDoc);
+  server.addPath ("/api/sensors", onApiSensors);
+  server.addPath ("/api/control", onApiControl);
+  server.addPath ("/config", onConfiguration);
+  server.setDefaultHandler (onFile);
+  serverStarted = true;
+  /*
+   if (WifiStation.isEnabled())
+   debugf("STA: %s", WifiStation.getIP().toString().c_str());
+   if (WifiAccessPoint.isEnabled())
+   debugf("AP: %s", WifiAccessPoint.getIP().toString().c_str());
+   */
 }
 }

+ 25 - 24
include/configuration.h

@@ -6,8 +6,8 @@
 
 
 // If you want, you can define WiFi settings globally in Eclipse Environment Variables
 // If you want, you can define WiFi settings globally in Eclipse Environment Variables
 #ifndef WIFI_SSID
 #ifndef WIFI_SSID
-	#define WIFI_SSID "Heaven-WiFi" // Put you SSID and Password here
-	#define WIFI_PWD "Heaven-32847"
+#define WIFI_SSID "Heaven-WiFi" // Put you SSID and Password here
+#define WIFI_PWD "Heaven-32847"
 #endif
 #endif
 
 
 #define PinSet(pin)		GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, ((uint16_t)1<<(pin)))
 #define PinSet(pin)		GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, ((uint16_t)1<<(pin)))
@@ -26,34 +26,35 @@
 #define PIN_LOAD	12
 #define PIN_LOAD	12
 #define MAX7219_DIGITS	8
 #define MAX7219_DIGITS	8
 
 
-
 #define CLOCK_CONFIG_FILE ".clock.conf" // leading point for security reasons :)
 #define CLOCK_CONFIG_FILE ".clock.conf" // leading point for security reasons :)
 
 
 struct ClockConfig
 struct ClockConfig
 {
 {
-	ClockConfig()
-	{
-		AddTZ = 2;
-		LightTrhLow = 341;
-		LightTrhHigh = 683;
-		BrightnessLow = 1;
-		BrightnessMiddle = 7;
-		BrightnessHigh = 15;
-	}
-
-	String NetworkSSID;
-	String NetworkPassword;
-
-	float AddTZ; // TimeZone - local time offset
-	uint16_t LightTrhLow; // Low Light level
-	uint16_t LightTrhHigh; // High Light level
-	int8_t BrightnessLow; // Low LED brightness level
-	int8_t BrightnessMiddle; // Middle LED brightness level
-	int8_t BrightnessHigh; // High LED brightness level
+  ClockConfig ()
+  {
+    AddTZ = 2;
+    LightTrhLow = 341;
+    LightTrhHigh = 683;
+    BrightnessLow = 1;
+    BrightnessMiddle = 7;
+    BrightnessHigh = 15;
+  }
+
+  String NetworkSSID;
+  String NetworkPassword;
+
+  float AddTZ; // TimeZone - local time offset
+  uint16_t LightTrhLow; // Low Light level
+  uint16_t LightTrhHigh; // High Light level
+  int8_t BrightnessLow; // Low LED brightness level
+  int8_t BrightnessMiddle; // Middle LED brightness level
+  int8_t BrightnessHigh; // High LED brightness level
 };
 };
 
 
-ClockConfig loadConfig();
-void saveConfig(ClockConfig& cfg);
+ClockConfig
+loadConfig ();
+void
+saveConfig (ClockConfig& cfg);
 
 
 extern ClockConfig ActiveConfig;
 extern ClockConfig ActiveConfig;
 
 

+ 6 - 4
include/max7219.h

@@ -10,7 +10,8 @@
 
 
 // symbols
 // symbols
 // Для BCD
 // Для BCD
-#define MAX7219_CHAR_BLANK	0x00
+#define MAX7219_CHAR_BLANK	0x0F
+#define MAX7219_CHAR_MINUS	0x0A
 #define MAX7219_CHAR_FULL	0xFF
 #define MAX7219_CHAR_FULL	0xFF
 // без кодирования
 // без кодирования
 #define SYM_Gradus			0x63
 #define SYM_Gradus			0x63
@@ -55,8 +56,9 @@
 #define SEG_G					0
 #define SEG_G					0
 #define SEG_DP					7
 #define SEG_DP					7
 
 
-void MAX7219_writeData(uint8_t data_register, uint8_t data);
-void MAX7219_Init(void);
-
+void
+MAX7219_writeData (uint8_t data_register, uint8_t data);
+void
+MAX7219_Init (void);
 
 
 #endif /* INCLUDE_MAX7219_H_ */
 #endif /* INCLUDE_MAX7219_H_ */

+ 27 - 26
include/user_config.h

@@ -2,41 +2,42 @@
 #define __USER_CONFIG_H__
 #define __USER_CONFIG_H__
 
 
 #ifdef __cplusplus
 #ifdef __cplusplus
-extern "C" {
+extern "C"
+{
 #endif
 #endif
 
 
-	// UART config
-	#define SERIAL_BAUD_RATE 115200
+// UART config
+#define SERIAL_BAUD_RATE 115200
 
 
-	// ESP SDK config
-	#define LWIP_OPEN_SRC
-	#define USE_US_TIMER
+// ESP SDK config
+#define LWIP_OPEN_SRC
+#define USE_US_TIMER
 
 
-	// Default types
-	#define __CORRECT_ISO_CPP_STDLIB_H_PROTO
-	#include <limits.h>
-	#include <stdint.h>
+// Default types
+#define __CORRECT_ISO_CPP_STDLIB_H_PROTO
+#include <limits.h>
+#include <stdint.h>
 
 
-	// Override c_types.h include and remove buggy espconn
-	#define _C_TYPES_H_
-	#define _NO_ESPCON_
+// Override c_types.h include and remove buggy espconn
+#define _C_TYPES_H_
+#define _NO_ESPCON_
 
 
-	// Updated, compatible version of c_types.h
-	// Just removed types declared in <stdint.h>
-	#include <espinc/c_types_compatible.h>
+// Updated, compatible version of c_types.h
+// Just removed types declared in <stdint.h>
+#include <espinc/c_types_compatible.h>
 
 
-	// System API declarations
-	#include <esp_systemapi.h>
+// System API declarations
+#include <esp_systemapi.h>
 
 
-	// C++ Support
-	#include <esp_cplusplus.h>
-	// Extended string conversion for compatibility
-	#include <stringconversion.h>
-	// Network base API
-	#include <espinc/lwip_includes.h>
+// C++ Support
+#include <esp_cplusplus.h>
+// Extended string conversion for compatibility
+#include <stringconversion.h>
+// Network base API
+#include <espinc/lwip_includes.h>
 
 
-	// Beta boards
-	#define BOARD_ESP01
+// Beta boards
+#define BOARD_ESP01
 
 
 #ifdef __cplusplus
 #ifdef __cplusplus
 }
 }

+ 4 - 3
include/webserver.h

@@ -1,8 +1,9 @@
 #ifndef INCLUDE_WEBSERVER_H_
 #ifndef INCLUDE_WEBSERVER_H_
 #define INCLUDE_WEBSERVER_H_
 #define INCLUDE_WEBSERVER_H_
 
 
-
-void startWebServer();
-void downloadContentFiles();
+void
+startWebServer ();
+void
+downloadContentFiles ();
 
 
 #endif /* INCLUDE_WEBSERVER_H_ */
 #endif /* INCLUDE_WEBSERVER_H_ */

+ 5 - 5
web/api.html

@@ -47,14 +47,14 @@
 			<div class="col-xs-10 col-md-5">
 			<div class="col-xs-10 col-md-5">
 			  <div class="panel panel-default">
 			  <div class="panel panel-default">
 					<div class="panel-heading">
 					<div class="panel-heading">
-						<h3 class="panel-title">Control output</h3>
+						<h3 class="panel-title">Control LED brightnes</h3>
 					</div>
 					</div>
 					<div class="panel-body">
 					<div class="panel-body">
-						<h4>http://{IP}/api/output?control=1</h4>
-						<p>Switch control output to HIGH state</p>
+						<h4>http://{IP}/api/control?bright=15</h4>
+						<p>Set LED bright to highest value.</p>
 						
 						
-						<h4>http://{IP}/api/output?control=0</h4>
-						<p>Switch control output to LOW state</p>
+						<h4>http://{IP}/api/control?bright=1</h4>
+						<p>Set LED bright to lowest value.</p>
 					</div>
 					</div>
 			  </div>
 			  </div>
 			</div>
 			</div>