Commits

Sebastian Bub committed 6f57dc5

bugfix with autotoggle list

Comments (0)

Files changed (3)

 
 6. Build the project
 mvn package
-(First build toke me about 4:30 min on raspi (with downloads), second took 3:30min))
+(First build toke me about 4:30 min on raspi (with downloads), second took 3:30min)
 
 7. Get Winstone Servlet Engine: http://winstone.sourceforge.net/
 put the jar in the same directory as the start.sh

src/main/java/de/derbub/rpigpio/gpio/GpioOutAutoToggleThread.java

         log.debug("run()");
         long absSleepTime = 0L;
         long currentDeltaSleepTime;
-        
+
         while (!gpioList.isEmpty()) {
             // find smallest auto toggle time
             long tmpSleepTime = 0L;
-            for(ConfiguredGpio gpio: gpioList){
-                if(tmpSleepTime == 0L){
+            for (ConfiguredGpio gpio : gpioList) {
+                if (tmpSleepTime == 0L) {
                     tmpSleepTime = gpio.getAutoToogleTime();
                 }
-                if(tmpSleepTime > gpio.getAutoToogleTime()){
+                if (tmpSleepTime > gpio.getAutoToogleTime()) {
                     tmpSleepTime = gpio.getAutoToogleTime();
                 }
             }
             // set new delta time
-            currentDeltaSleepTime = tmpSleepTime-absSleepTime;
+            currentDeltaSleepTime = tmpSleepTime - absSleepTime;
             absSleepTime = tmpSleepTime;
             try {
                 log.debug("run() sleep for " + currentDeltaSleepTime + " ms");
-				sleep(currentDeltaSleepTime);
-			} catch (InterruptedException e) {
-				log.error("run() interrupted (shutdown in progress?). Thread is stopped!");
+                sleep(currentDeltaSleepTime);
+            } catch (InterruptedException e) {
+                log.error("run() interrupted (shutdown in progress?). Thread is stopped!");
                 break;
-			}
+            }
             // after delta time, find notable
             Map<ConfiguredGpio, String> outGpioValueMap = new HashMap();
-            for(ConfiguredGpio gpio: gpioList){
-                if(gpio.getAutoToogleTime() == absSleepTime){
+            for (ConfiguredGpio gpio : gpioList) {
+                if (gpio.getAutoToogleTime() == absSleepTime) {
                     outGpioValueMap.put(gpio, Integer.toString(gpio.getDefaultState()));
                 }
             }
             gpioList.removeAll(outGpioValueMap.keySet());
             GpioSysFsInterface.getInstance().writeGpios(outGpioValueMap, true);
         }
+        log.debug("run() finished");
+
     }
 }

src/main/java/de/derbub/rpigpio/gpio/GpioSysFsInterface.java

                 if (SIMULATE_GPIOS) {
                     log.warn("Simulate set state " + value + (isAutoTogglingThread ? " (autoToggle)" : "") + " for " + gpio);
                     returnMap.put(gpio.getUserdefinedName(), value);
-                    if (!isAutoTogglingThread) {
+                    if (!isAutoTogglingThread && gpio.getAutoToogleTime() != ConfiguredGpio.NO_DEFAULT_TIME) {
                         autoToggleList.add(gpio);
                     }
                 } else {
                         aGpioFileWriter.flush();
                         log.info("Set state " + value + (isAutoTogglingThread ? " (autoToggle)" : "") + " for " + gpio);
                         returnMap.put(gpio.getUserdefinedName(), value);
-                        if (!isAutoTogglingThread) {
+                        if (!isAutoTogglingThread && gpio.getAutoToogleTime() != ConfiguredGpio.NO_DEFAULT_TIME) {
                             autoToggleList.add(gpio);
                         }
                     } else {