Ejemplo n.º 1
0
void make_some_job() {
  system("clear");
  switch(clock++ % 4) {
    case 0: {
      fillLeft();
      break;
    }

    case 1: {
      fillTop();
      break;
    }

    case 2: {
      fillRight();
      break;
    }

    case 3: {
      clock = 0;
      fillBottom();
      break;
    }
    default: break;
  }

  current_char = (current_char == 'z') ? 'a' : current_char + 1;

  draw();
}
Ejemplo n.º 2
0
bool BackupDevice::import_no_gba(const char *fname, u32 force_size)
{
	FILE	*fsrc = fopen(fname, "rb");
	u8		*in_buf = NULL;
	u8		*out_buf = NULL;

	if (fsrc)
	{
		u32 fsize = 0;
		fseek(fsrc, 0, SEEK_END);
		fsize = ftell(fsrc);
		fseek(fsrc, 0, SEEK_SET);
		//printf("Open %s file (size %i bytes)\n", fname, fsize);

		in_buf = new u8 [fsize];

		if (fread(in_buf, 1, fsize, fsrc) == fsize)
		{
			out_buf = new u8 [8 * 1024 * 1024 / 8];
			u32 size = 0;

			memset(out_buf, 0xFF, 8 * 1024 * 1024 / 8);
			if (no_gba_unpackSAV(in_buf, fsize, out_buf, size) == 0)
			{
				if (force_size > 0)
					size = force_size;
				//printf("New size %i byte(s)\n", size);
				size = trim(out_buf, size);
				//printf("--- new size after trim %i byte(s)\n", size);
				size = fillLeft(size);
				//printf("--- new size after fill %i byte(s)\n", size);
				raw_applyUserSettings(size, (force_size > 0));
				saveBuffer(out_buf, size, true, true);

				if (in_buf) delete [] in_buf;
				if (out_buf) delete [] out_buf;
				fclose(fsrc);
				return true;
			}
			if (out_buf) delete [] out_buf;
		}
		if (in_buf) delete [] in_buf;
		fclose(fsrc);
	}
	return false;
}
Ejemplo n.º 3
0
bool BackupDevice::no_gba_unpack(u8 *&buf, u32 &size)
{
	if (!buf) return false;
	u32 out_size = get_save_nogba_size(buf);
	if (out_size == 0xFFFFFFFF) return false;
	u8 *out_buf = new u8 [out_size];
	if (out_buf)
	{
		if (no_gba_unpackSAV(buf, size, out_buf, out_size) == 0)
		{
			out_size = trim(out_buf, out_size);
			out_size = fillLeft(out_size);
			delete [] buf;
			buf = out_buf;
			size = out_size;
			return true;
		}
	}

	delete out_buf;

	return false;
}
Ejemplo n.º 4
0
void HumanInterface::Print_graph(void)
{
	uint8_t i;
	double from;
	double to;
	rLCD->setMode(OVERWRITE);
	// Draw temperature graph
	for (i = 0; i < rTS->count-1; i++) {
		from = (double)(rTS->tempC[i] - MIN_TEMP) * 48 / (MAX_TEMP - MIN_TEMP);
		to = (double)(rTS->tempC[i + 1] - MIN_TEMP) * 48 / (MAX_TEMP - MIN_TEMP);
		fillLeft(from,i*84/(rTS->count-1) , to, (i+1)*84/(rTS->count-1) );
	}
	// print temperature of the top of accumulator 
	rLCD->setMode(XOR);
	BufferIndex=0;
	print((int)rTS->tempC[0],DEC);
	if (rTS->tempC[0] < (MAX_TEMP-MIN_TEMP)/2+MIN_TEMP) {
		rLCD->GoTo(48-strlen((const char *)Buffer)*8-7, 4);
	} else {
		rLCD->GoTo(4, 4);
	}
	rLCD->setFont(&BIGSERIF[0][0],8,14,F_UP_DOWN);
	rLCD->print((const char *)Buffer);
	rLCD->setFont(&font5x8[0][0],5,8,F_LEFT_RIGHT);
	rLCD->print('c');

	//Print temperature of the bottom of accumulator
	BufferIndex=0;
	print((int)rTS->tempC[rTS->count-1],DEC);
	// Get accumulator temperature near the bottom to decide where to print temperature
	i=rTS->count-1; // index of last (bottom) thermometer;
	if(i>0) { // Normaly there are more than one thermometer and bottom temperatur is printed in the best free space.
		i--;
	}
	if (rTS->tempC[i] < (MAX_TEMP-MIN_TEMP)/2+MIN_TEMP) {
		rLCD->GoTo(48-strlen((const char *)Buffer)*8-7, 84-14-4);
	} else {
		rLCD->GoTo(4, 84-14-4);
	}
	rLCD->setFont(&BIGSERIF[0][0],8,14,F_UP_DOWN);
	rLCD->print((const char *)Buffer);
	rLCD->setFont(&font5x8[0][0],5,8,F_LEFT_RIGHT);
	rLCD->print('c');

	//print useful Mega calories. Assume accumulator size 1000liters
	double Mcal=0;
	double Mcal_full=MAX_TEMP-MIN_TEMP;
	double temp;
	uint8_t* p;
	for (i = 0; i < rTS->count-1; i++) {
		temp=(rTS->tempC[i]+rTS->tempC[i + 1])/2-MIN_TEMP;
		if(temp<0) {
			temp=0;
		}
		Mcal+=temp/5;
	}	

	BufferIndex=0;
	print((double)Mcal*100.0/Mcal_full,2);
	p=Buffer;
	rLCD->GoTo(10,42-14);
	if(Mcal>Mcal_full) {
		rLCD->GoTo(2,42-14);
	}
	rLCD->setFont(&BIGSERIF[0][0],8,14,F_UP_DOWN);
	while(*p) {
		rLCD->putChar(*(p++));
		if(*p=='.') {
			p++;
			break;
		}
	}	
	rLCD->setFont(&font5x8[0][0],5,8,F_LEFT_RIGHT);
	rLCD->GoTo(rLCD->cursorX+1,rLCD->cursorY+5);
	while(*p) {
		rLCD->putChar(*(p++));
	}	
	rLCD->GoTo(rLCD->cursorX+1,rLCD->cursorY-5);
	rLCD->setFont(&BIGSERIF[0][0],8,14,F_UP_DOWN);
	rLCD->putChar('%');


	BufferIndex=0;
	// strlen from 8 bit font + 20 points ("Mcal" font 5) 
	print((int)Mcal,DEC);
	rLCD->GoTo(24-(strlen((const char *)Buffer)*8+20)/2,42);
	rLCD->setFont(&BIGSERIF[0][0],8,14,F_UP_DOWN);
	rLCD->print((const char *)Buffer);

	rLCD->setFont(&font5x8[0][0],5,8,F_LEFT_RIGHT);
	rLCD->GoTo(rLCD->cursorX,rLCD->cursorY+5);
	rLCD->print("Mcal");


	rLCD->setMode(OVERWRITE);
}