MCPcopy Create free account
hub / github.com/dborth/vbagx / systemUpdateSolarSensor

Function systemUpdateSolarSensor

source/vbasupport.cpp:624–698  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

622}
623
624void systemUpdateSolarSensor()
625{
626 u8 sun = 0x0; //sun = 0xE8 - 0xE8 (case 0 and default)
627
628 switch (SunBars)
629 {
630 case 1:
631 sun = 0xE8 - 0xE0;
632 break;
633 case 2:
634 sun = 0xE8 - 0xDA;
635 break;
636 case 3:
637 sun = 0xE8 - 0xD0;
638 break;
639 case 4:
640 sun = 0xE8 - 0xC8;
641 break;
642 case 5:
643 sun = 0xE8 - 0xC0;
644 break;
645 case 6:
646 sun = 0xE8 - 0xB0;
647 break;
648 case 7:
649 sun = 0xE8 - 0xA0;
650 break;
651 case 8:
652 sun = 0xE8 - 0x88;
653 break;
654 case 9:
655 sun = 0xE8 - 0x70;
656 break;
657 case 10:
658 sun = 0xE8 - 0x50;
659 break;
660 default:
661 break;
662 }
663
664 struct tm *newtime;
665 time_t long_time;
666
667 // regardless of the weather, there should be no sun at night time!
668 time(&long_time); // Get time as long integer.
669 newtime = localtime(&long_time); // Convert to local time.
670 if (newtime->tm_hour > 21 || newtime->tm_hour < 5)
671 {
672 sun = 0; // total darkness, 9pm - 5am
673 }
674 else if (newtime->tm_hour > 20 || newtime->tm_hour < 6)
675 {
676 sun /= 9; // almost total darkness 8pm-9pm, 5am-6am
677 }
678 else if (newtime->tm_hour > 18 || newtime->tm_hour < 7)
679 {
680 sun >>= 1;
681 }

Callers 1

systemUpdateMotionSensorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected