示例#1
0
void systick () {
	stateTicks++;
	if (typeTicks >= 0) typeTicks++;

	//Check if button was pressed. TODO: Disable button events in certain states
	bool buttonDown = !any_gpio_read (KEY_PORT, KEY_PIN);
	if (buttonDown && !buttonWasDown && (typeTicks < 0)) {
		typeTicks = 0;
		if ((state == State_AllOff) || (state == State_Alone)) {
			state = State_Alone;
			stateTicks = 0;
		} 
	}
	buttonWasDown = buttonDown;

	//Special case no feedback: If we're all alone, go back to alloff after a while
	if ((state == State_Alone) && (stateTicks > LIGHT_ON_DURATION)) {
		state = State_AllOff;
		stateTicks = 0;
	}
	
	//Send typing HID events.
	if (typeTicks == 0) {
		SendKey(keys[myButtonIdx]);
	} else if (typeTicks == KEY_DOWN_DURATION) {
		SendKey(0);
		typeTicks = -1;
	}

	//Set RGB color according to state
	if (state <= State_P1_P2_P3_Enabled) {
		bool on = state & (1 << myButtonIdx);
		SetRGBColor(on ? &colors[myButtonIdx] : &black);
	} else if ((state >= State_P1_Only) && (state <= State_P3_Urgent)) {
		bool blink = state >= State_P1_Urgent;
		int activeButtonIdx = (state - State_P1_Only) % numButtons;
		bool on = blink ? ((stateTicks & 0x10) == 0) : true;
		SetRGBColor(on ? &colors[activeButtonIdx] : &black);
	} else if (state == State_Rainbow) {
		int fromIdx = (stateTicks >> 7) % 6;
		int toIdx = (fromIdx + 1) % 6;
		uint32_t weight_to   = stateTicks & 0x7f;
        uint32_t weight_from = 0x80 - weight_to;
        uint32_t r = (weight_from * rainbowColors[fromIdx].r + weight_to * rainbowColors[toIdx].r ) >> 7;
        uint32_t g = (weight_from * rainbowColors[fromIdx].g + weight_to * rainbowColors[toIdx].g ) >> 7;
        uint32_t b = (weight_from * rainbowColors[fromIdx].b + weight_to * rainbowColors[toIdx].b ) >> 7;
        RGBColor blendColor = { r,g,b };
		SetRGBColor(&blendColor);
	} else if (state == State_Alone) {
示例#2
0
static int SetGlobalString(long what, const char *string) {
    STARTFUNC("SetGlobalString");
    LOG << "What: " << what << " String: " << string << ENDLINE;

    switch (what) {
    case FLAG_DefaultModeName: strlcpy(DefaultModeName, string, sizeof(DefaultModeName)); break;
    case FLAG_CompletionFilter: if ((CompletionFilter = RxCompile(string)) == NULL) return -1; break;
    case FLAG_PrintDevice: strlcpy(PrintDevice, string, sizeof(PrintDevice)); break;
    case FLAG_CompileCommand: strlcpy(CompileCommand, string, sizeof(CompileCommand)); break;
    case FLAG_WindowFont: strlcpy(WindowFont, string, sizeof(WindowFont)); break;
    case FLAG_HelpCommand: strlcpy(HelpCommand, string, sizeof(HelpCommand)); break;
    case FLAG_GUICharacters: AppendGUICharacters (string); break;
#ifdef CONFIG_OBJ_CVS
    case FLAG_CvsCommand: strlcpy(CvsCommand, string, sizeof(CvsCommand)); break;
    case FLAG_CvsLogMode: strlcpy(CvsLogMode, string, sizeof(CvsLogMode)); break;
#endif
#ifdef CONFIG_OBJ_SVN
    case FLAG_SvnCommand: strlcpy(SvnCommand, string, sizeof(SvnCommand)); break;
    case FLAG_SvnLogMode: strlcpy(SvnLogMode, string, sizeof(SvnLogMode)); break;
#endif
    case FLAG_RGBColor: SetRGBColor(string); break;
    case FLAG_XShellCommand: strlcpy(XShellCommand, string, sizeof(XShellCommand)); break;
    default:
        //printf("Unknown global string: %ld\n", what);
        ENDFUNCRC(-1);
    }
    ENDFUNCRC(0);
}
示例#3
0
/* the worst possible thing that could happen here is for a later release of the system
	software to change how the default window colors are stored, which would cause this
	function to assume the default blue/purple colors.  this is only a problem because
	the system then wonÕt have the colors it wants to draw window frames and controls.
	but this itself is ok, because the system is smart about doing this and there might
	even be enough shades of gray to go around. */
void initialize_system_colors(
	void)
{
	CTabHandle default_wctb;

	default_wctb= (CTabHandle) GetResource('wctb', 0);
	if (default_wctb)
	{
		if ((*default_wctb)->ctSize>=12)
		{
			if ((*default_wctb)->ctTable[wHighlightColor].value==wHighlightColor&&
				(*default_wctb)->ctTable[wLowlightColor].value==wLowlightColor)
			{
				/* we have system seven or later with the right part codes! */
				system_colors[windowLowlight]= (*default_wctb)->ctTable[wLowlightColor].rgb;
				system_colors[windowHighlight]= (*default_wctb)->ctTable[wHighlightColor].rgb;
			}
		}
		
		/* we canÕt dispose of this, because other people are using it */
	}
	
	/* interpolate to get the two shades between the highlight and lowlight */
	SetRGBColor(system_colors+window33Percent,
		(2*(long)system_colors[windowLowlight].red+(long)system_colors[windowHighlight].red)/3,
		(2*(long)system_colors[windowLowlight].green+(long)system_colors[windowHighlight].green)/3,
		(2*(long)system_colors[windowLowlight].blue+(long)system_colors[windowHighlight].blue)/3);
	SetRGBColor(system_colors+window66Percent,
		((long)system_colors[windowLowlight].red+2*(long)system_colors[windowHighlight].red)/3,
		((long)system_colors[windowLowlight].green+2*(long)system_colors[windowHighlight].green)/3,
		((long)system_colors[windowLowlight].blue+2*(long)system_colors[windowHighlight].blue)/3);

	/* get the highlight color */
	LMGetHiliteRGB(system_colors+highlightColor);

	return;
}
示例#4
0
void VectDraw(DialogPtr d, Rect *rectPtr, long itemNumber)
{
#pragma unused (rectPtr)
	Point		p;
	short		h,v;
	RGBColor	rgb;
	Rect		rgbrect;
	char 		numstr[30],numstr2[30];
	double 		x  = (*gEditContourLevels)[itemNumber];
	float		colorLevel;
	long		numLevels = GetNumDoubleHdlItems(gEditContourLevels);
	
	SetRGBColor(&rgb,0,0,0);

	TextFont(kFontIDGeneva); TextSize(LISTTEXTSIZE);
	
	rgbrect=GetDialogItemBox(d,CONT_LISTID);
	h=(rgbrect.left);
	GetPen(&p);
	v=p.v;

	MySetRect(&rgbrect,h+4,v-9,h+14,v+1);
	
	// set unique color for each value, not on linear scale
	colorLevel = float(itemNumber)/float(numLevels-1);
	//rgb = GetRGBColor(colorLevel);
#ifdef IBM
	rgb = GetRGBColor(colorLevel);
#else
	rgb = GetRGBColor(1.-colorLevel);
#endif
	//rgb = GetRGBColor(0.8-colorLevel);
	RGBForeColor(&rgb);
	PaintRect(&rgbrect);
	MyFrameRect(&rgbrect);

	MyMoveTo(h+30,v+1);

	RGBForeColor(&colors[BLACK]);
	if (itemNumber<numLevels-1)
	{
		MyNumToStr(x,numstr);
		MyNumToStr((*gEditContourLevels)[itemNumber+1],numstr2);
		strcat(numstr," - ");
		strcat(numstr,numstr2);
	}
	else
	{
		strcpy(numstr,"> ");
		MyNumToStr(x,numstr2);
		strcat(numstr,numstr2);
	}
	if (gContourType==0)
	{
		strcat(numstr,"    mg/L");
	}
	else
	{
		MyNumToStr(x,numstr);
		strcat(numstr,"    m");
	}
	//drawstring(MyNumToStr(x,numstr));
	drawstring(numstr);
 
	return;
}