PiSupply / PiJuice

Resources for PiJuice HAT for Raspberry Pi - use your Pi Anywhere
https://www.pi-supply.com/product/pijuice-standard/
GNU General Public License v3.0
433 stars 102 forks source link

Wakeup SetAlarm Cannot Set Multiple Days #1069

Open quitmeyer opened 3 months ago

quitmeyer commented 3 months ago

Hi, I have a pijuice on a pi4 and discovered that it seems to be impossible to set the "day"

I have noted this in the comments of a couple other posts, but figured it should be a standalone issue https://github.com/PiSupply/PiJuice/issues/489

i noticed that you can set multiple minutes or hours by specifying them with a semicolon (like 3;4;8) but if you try to set day: 3;4;8 it throws an invalid error. You can however specify multiple weekdays

The root of this problem seems that it is actually just in the source code. ` if 'weekday' in alarm: try: day = alarm['weekday'] if day == 'EVERY_DAY': d[3] = 0x80 | 0x40

            elif isinstance(day, str) and day.find(';') < 0:
                dw = int(day)
                d[3] = d[3] | (dw & 0x0F) | 0x40

            elif isinstance(day, int):
                dw = int(day)
                d[3] = d[3] | (dw & 0x0F) | 0x40

            elif (isinstance(day, str) and day.find(';') >= 0):
                d[3] = 0x40 | 0x80
                ds = 0x00
                dl = day.split(';')
                dl = dl[0:-1] if (not bool(dl[-1].strip())) else dl
                for i in dl:
                    ds = ds | (0x01 << int(i))
                d[8] = ds
        except:
            return {'error': 'INVALID_WEEKDAY'}
    elif 'day' in alarm:
        try:
            day = alarm['day']
            if day == 'EVERY_DAY':
                d[3] = 0x80

            else:
                dm = int(day)
                d[3] = (((dm // 10) & 0x03) << 4)
                d[3] = d[3] | ((dm % 10) & 0x0F)
        except:
            return {'error': 'INVALID_DAY_OF_MONTH'}
    else:
        d[3] = 0x80  # every day

`

does anyone know if there's a workaround to doing this? or if the source code can be patched to allow multiple days to be entered?