Multiple water level module status

Expansion modules and attachments
Post Reply
Smotz
Posts: 412
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Multiple water level module status

Post by Smotz »

Any updates ?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Multiple water level module status

Post by rimai »

I've got a couple, but the libraries are not finalized yet.
The calibration code I have isn't working right.
Roberto.
Smotz
Posts: 412
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: Multiple water level module status

Post by Smotz »

let me know. Going on vacation soon and will need to set up the ATO
Piper
Posts: 296
Joined: Fri Jul 20, 2012 7:13 am
Location: Oakley, CA

Re: Multiple water level module status

Post by Piper »

rimai wrote:I've got a couple, but the libraries are not finalized yet.
The calibration code I have isn't working right.
I'll post my modified code after I get home tonight. It calibrates all 5 ports (single at port 0, and the multi on ports 1 - 4) and seems to be working for me. I'm only using port 1 at the moment and it's calibrating and reading correctly.
Piper
Posts: 296
Joined: Fri Jul 20, 2012 7:13 am
Location: Oakley, CA

Re: Multiple water level module status

Post by Piper »

Here's what I used:

Code: Select all

#ifdef WATERLEVELEXPANSION
void ReefAngelClass::SetupCalibrateWaterLevel()
{
	bool bOKSel = false;
	bool bSave = false;
	bool bDone = false;
	bool bDrawButtons = true;
	unsigned int iO[10] = {0,0,0,0,0,0,0,0,0,0};
	unsigned int iCal[2] = {0,100};
	byte offset = 65;
	// draw labels
	ClearScreen(DefaultBGColor);
	for (int b=0;b<10;b++)
	{
		if (b==10 && !bSave) break;
		bOKSel=false;
		bSave=false;
		bDone = false;
		bDrawButtons = true;
		LCD.DrawText(DefaultFGColor, DefaultBGColor, MENU_START_COL, MENU_START_ROW, "Calibrate Water Level");
		char port[10] = "Port: ";
		itoa(b/2,port,10);
		LCD.DrawText(DefaultFGColor, DefaultBGColor, MENU_START_COL, MENU_START_ROW+16, port);
		char text[10] = "";
		itoa(iCal[b%2],text,10);
		strcat(text , " %  ");
		LCD.DrawText(DefaultFGColor, DefaultBGColor, MENU_START_COL, MENU_START_ROW*5, text);
		do
		{
#if defined WDT || defined WDT_FORCE
			wdt_reset();
#endif  // defined WDT || defined WDT_FORCE
			iO[b]=0;
			for (int a=0;a<15;a++) {
				iO[b] += WaterLevel.Read(b/2);
			}
			iO[b]/=15;
			LCD.DrawCalibrate(iO[b], MENU_START_COL + offset, MENU_START_ROW*5);
			if (  bDrawButtons )
			{
				if ( bOKSel )
				{
					LCD.DrawOK(true);
					LCD.DrawCancel(false);
				}
				else
				{
					LCD.DrawOK(false);
					LCD.DrawCancel(true);
				}
				bDrawButtons = false;
			}
			if ( Joystick.IsUp() || Joystick.IsDown() || Joystick.IsRight() || Joystick.IsLeft() )
			{
				// toggle the selection
				bOKSel = !bOKSel;
				bDrawButtons = true;
			}
			if ( Joystick.IsButtonPressed() )
			{
				bDone = true;
				if ( bOKSel )
				{
					bSave = true;
				}
			}
		} while ( ! bDone );
	}
	ClearScreen(DefaultBGColor);
	if ( bSave )
	{
		// save WaterLevelMin & WaterLevelMax to memory
		InternalMemory.WaterLevelMin_write(iO[0]);
		InternalMemory.WaterLevelMax_write(iO[1]);
		InternalMemory.WaterLevel1Min_write(iO[2]);
		InternalMemory.WaterLevel1Max_write(iO[3]);
		InternalMemory.WaterLevel2Min_write(iO[4]);
		InternalMemory.WaterLevel2Max_write(iO[5]);
		InternalMemory.WaterLevel3Min_write(iO[6]);
		InternalMemory.WaterLevel3Max_write(iO[7]);
		InternalMemory.WaterLevel4Min_write(iO[8]);
		InternalMemory.WaterLevel4Max_write(iO[9]);
	}
}
#endif  // WATERLEVELEXPANSION
phrusher
Posts: 65
Joined: Fri May 25, 2012 12:22 am

Re: Multiple water level module status

Post by phrusher »

Any updates? Is it possible to run two single modules together?
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Multiple water level module status

Post by rimai »

These module is available in the web store :)
It's a 4 port module.
Roberto.
phrusher
Posts: 65
Joined: Fri May 25, 2012 12:22 am

Re: Multiple water level module status

Post by phrusher »

I have one single module and I just placed an order for an additional single module before seeing this thread :/

Sent from my Nexus 5 using Tapatalk
Post Reply