rszimm / sprinklers_pi

Sprinkling System Control Program for the Raspberry Pi
GNU General Public License v2.0
310 stars 100 forks source link

Zone duration too short #37

Closed Shaker666 closed 5 years ago

Shaker666 commented 9 years ago

I've got a citrus zone that requires up to 20 hours of continuous drip irrigation for a deep soak every couple of weeks. Would it be possible to extend the maximum zone duration to 2000 minutes or more?

Shaker666 commented 8 years ago

Nobody? It's been a year and nobody has even responded. If someone could point me to the right area to poke at in code, I'll make the change myself!

Took a closer look inside Core.cpp::LoadSchedTimeEvents(). The events processing encodes some data into data[1] and data[2] which I suspect is what is limiting the overall duration. Since it's bits and bytes however, I'm not entirely sure. If anyone could help point out exactly what's going on, I'd be super grateful.

tony-osp commented 8 years ago

First of all you need to change definition of zone_duration in settings.h to uint16_t from uint8_t, this will allow run time of up to 64K minutes. Because of allocation of two bytes per run time (which is per-zone in a schedule) you will also need to increase schedule size in EEPROM image (SCHEDULE_INDEX), which in turn may require tweaking EEPROM layout - you will need to either reduce the maximum number of schedules, or use bigger EEPROM image (e.g. 4K instead of 2K).

All of this is perfectly doable, but involves quite a bit of work.

nhorvath commented 8 years ago

Thanks @tony-osp. I do want to mention though that if he's using it on a raspberry pi and not an arduino he can ignore the eeprom stuff.

Shaker666 commented 8 years ago

Yep, running RPi. I had made the change to uint16_t for zone_duration[] in Schedule a long time ago, but the issue I was seeing was that something is enforcing the maximum duration to 100 minutes, perhaps from the UI. I couldn't quite figure out what was doing this, although I suspect it might be in Core.cpp::LoadSchedTimeEvents().

Thanks for responding, btw... I really appreciate having a dialog with anyone on this!

tony-osp commented 8 years ago

Yes, there is also code in the UI that imposes this restriction, in QSched.html:

function addQZone(j, name, enabled, duration) { var zone_id = 'z' + String.fromCharCode(97+j); var new_ctl = $('<div data-role="fieldcontain"><label for="' + zone_id + '">' + j +':' + name + ' Duration:</label><input type="range" name="' + zone_id + '" id="' + zone_id + '" value="' + duration + '" min="0" max="100" /></div>'); new_ctl.appendTo('#qzones'); } You will need to update it to lift restriction. There could be also other places where restrictions are applied, I have not checked it.

... The EEPROM space allocation is actually still important on RPi - the way how Sprinklers_pi handles settings on RPi is by creating an in-memory (in RAM) image of EEPROM, working with it by updating elements of that image and then writing the whole image to a file. The buffer is called m_buf (defined in port.h), and has size of 2048 bytes. If increasing per-zone duration to two bytes (from one) you need to either decrease the total number of schedules, or increase m_buf size to accommodate bigger schedule blocks and update offsets etc.

With best regards Tony

Shaker666 commented 8 years ago

Brilliant. Thanks very much. I'll make these mods and post my results.

Cheers!

dalgatatar commented 8 years ago

Hello to everyone. this project is perfect. pls help me i want long Zone duration max 8 hours. if someone do this and extend Zone duration send me details pls. i try here other examples and fix Zone duration scale on web page side but when save settings change time pls help me thnx

EMarijke commented 6 years ago

Hi there, I'm completely new on GitHub on do not have a lot of Raspberry Pi experience either. I also need a water supply for more than 100 mins, something around 12 hours. So I'd be very interested in Shaker666's results, if you got anywhere and are still willing to share them. Thanks!

nhorvath commented 6 years ago

Your best bet would be to get @Shaker666 or @dchapma1 (different thread same problem solved) to fork the repo and commit their changes so you could use them.

Whytehorse commented 6 years ago

I'm also affected by this. I can see in settings.h I have uint8_t zone_duration[15]. This means the max I can have is 255 min(4.25hr)? That works for me so I just update the gui code and it will work? no recompile necessary?

nhorvath commented 6 years ago

Yes, uint8_t can hold 0 - 255.

On Thu, Apr 26, 2018 at 11:19 AM, Whytehorse notifications@github.com wrote:

I'm also affected by this. I can see in settings.h I have uint8_t zone_duration[15]. This means the max I can have is 255 min(4.25hr)? That works for me so I just update the gui code and it will work? no recompile necessary?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rszimm/sprinklers_pi/issues/37#issuecomment-384680228, or mute the thread https://github.com/notifications/unsubscribe-auth/AAKE3IT5Ykkm77EGIpqNvitPOxv7Uh5vks5tseVvgaJpZM4D2Y9o .

Whytehorse commented 5 years ago

Can we get this permanently fixed? Zone duration should not be limited to 100min, especially now that drip systems are ubiquitous.

nhorvath commented 5 years ago

@Whytehorse I increased the duration validation to 255 minutes. Note: scaling (either weather or seasonal) is still limited to 255 min max as well so if you create a duration with 255 minutes it will not be able to scale past 100%. It would be better to have 2 scheduled runtimes for your schedule and half the individual duration.