コード例 #1
0
uint8_t Remote::send(uint8_t id, uint8_t type)
{
	switch(id)
	{
		case REMOTE_BATTERY:
			return bt.sendDATA(id, type, (void *) &battery_percent, sizeof(battery_percent));
		case REMOTE_STATUS:
			return bt.sendDATA(id, type, (void *) &timer.status, sizeof(timer.status));
		case REMOTE_PROGRAM:
			return bt.sendDATA(id, type, (void *) &timer.current, sizeof(timer.current));
		case REMOTE_MODEL:
		{
			uint8_t tmp = REMOTE_MODEL_TLP;
			return bt.sendDATA(id, type, (void *) &tmp, sizeof(uint8_t));
		}
		case REMOTE_FIRMWARE:
		{
			unsigned long version = VERSION;
			void *ptr = &version;
			return bt.sendDATA(id, type, ptr, sizeof(version));
		}
		case REMOTE_BT_FW_VERSION:
		{
			uint8_t btVersion = bt.version();
			return bt.sendDATA(id, type, (void *) &btVersion, sizeof(btVersion));
		}
		case REMOTE_PROTOCOL_VERSION:
		{
			unsigned long remoteVersion = REMOTE_VERSION;
			void *ptr = &remoteVersion;
			return bt.sendDATA(id, type, ptr, sizeof(remoteVersion));
		}
		case REMOTE_CAMERA_FPS:
			return bt.sendDATA(id, type, (void *) &conf.cameraFPS, sizeof(conf.cameraFPS));
		case REMOTE_CAMERA_MAKE:
			return bt.sendDATA(id, type, (void *) &conf.cameraMake, sizeof(conf.cameraMake));
		case REMOTE_ISO:
		{
			uint8_t tmp = camera.iso();
			return bt.sendDATA(id, type, (void *) &tmp, sizeof(tmp));
		}
		case REMOTE_APERTURE:
		{
			uint8_t tmp = camera.aperture();
			return bt.sendDATA(id, type, (void *) &tmp, sizeof(tmp));
		}
		case REMOTE_SHUTTER:
		{
			uint8_t tmp = camera.shutter();
			return bt.sendDATA(id, type, (void *) &tmp, sizeof(tmp));
		}
		case REMOTE_VIDEO:
		{
			uint8_t tmp = camera.recording;
			return bt.sendDATA(id, type, (void *) &tmp, sizeof(tmp));
		}
		case REMOTE_LIVEVIEW:
		{
			uint8_t tmp = camera.modeLiveView;
			return bt.sendDATA(id, type, (void *) &tmp, sizeof(tmp));
		}
		case REMOTE_THUMBNAIL:
		{
			menu.message(STR("Busy"));
/*
			uint8_t ret = camera.getCurrentThumbStart();
			if(ret != PTP_RETURN_ERROR)
			{
				bt.sendDATA(REMOTE_THUMBNAIL_SIZE, type, (void *) &PTP_Bytes_Total, sizeof(PTP_Bytes_Total));
				bt.sendDATA(id, type, (void *) PTP_Buffer, PTP_Bytes_Received);
				while(ret == PTP_RETURN_DATA_REMAINING)
				{
					ret = camera.getCurrentThumbContinued();
					bt.sendDATA(id, type, (void *) PTP_Buffer, PTP_Bytes_Received);
				}
			}
*/
			///////////////////////// DEMO Code ////////////////////////////
			PTP_Bytes_Total = sizeof(thm);
			bt.sendDATA(REMOTE_THUMBNAIL_SIZE, type, (void *) &PTP_Bytes_Total, sizeof(PTP_Bytes_Total));
			uint16_t total_sent = 0, i;
			while(total_sent < PTP_Bytes_Total)
			{
				for(i = 0; i < PTP_BUFFER_SIZE; i++)
				{
					PTP_Buffer[i] = pgm_read_byte(&thm[i + total_sent]);
					if(total_sent + i >= PTP_Bytes_Total) break;
				}
				PTP_Bytes_Received = i;
				total_sent += PTP_Bytes_Received;
				if(PTP_Bytes_Received == 0) break;
				bt.sendDATA(id, type, (void *) PTP_Buffer, PTP_Bytes_Received);
				if(total_sent >= PTP_Bytes_Total) break;
			}
			/////////////////////////////////////////////////////////////////
			return 0;
		}
		default:
			return bt.sendDATA(id, type, 0, 0);
	}
	return 0;
}
コード例 #2
0
volatile char sysInfo(char key, char first)
{
	if(first)
	{
		lcd.cls();

		char l;
		char* text;
		char buf[6];
		uint16_t val;

		// Lines (Y) = 6, 12, 18, 24, 30
		val = (uint16_t)bt.version();

		text = TEXT("TLP01");
		l = lcd.measureStringTiny(text);
		lcd.writeStringTiny(80 - l, 6 + SY, text);
		lcd.writeStringTiny(3, 6 + SY, TEXT("Model:"));

		if(val > 1)
			text = TEXT("BTLE");
		else
			text = TEXT("KS99");

		l = lcd.measureStringTiny(text);
		lcd.writeStringTiny(80 - l, 12 + SY, text);
		lcd.writeStringTiny(3, 12 + SY, TEXT("Edition:"));

		lcd.writeStringTiny(3, 18 + SY, TEXT("Firmware:"));
		uint32_t version = VERSION;

		char c;

		l = 0;

		while(version)
		{
			c = (char)(version % 10);
			buf[0] = ((char)(c + '0'));
			buf[1] = 0;
			text = buf;
			l += lcd.measureStringTiny(text) + 1;
			lcd.writeStringTiny(80 - l, 18 + SY, text);

			version -= (uint32_t)c;
			version /= 10;
		}

		if(val > 1)
		{
			int_to_str(val, buf);
			text = buf;
			l = lcd.measureStringTiny(text);
			lcd.writeStringTiny(80 - l, 30 + SY, text);
			lcd.writeStringTiny(3, 30 + SY, TEXT("BT FW Version:"));
		}

		menu.setTitle(TEXT("System Info"));
		menu.setBar(TEXT("RETURN"), BLANK_STR);
		lcd.update();
	}

	if(key == FL_KEY || key == LEFT_KEY)
		return FN_CANCEL;

	return FN_CONTINUE;
}