Пример #1
0
void ButtonMachine::ledPipe()
{
	Points points;
	RGBPixel rgb;
	uint32_t color, r, g, b, n;
	g_blobs->m_clut.growRegion(g_rawFrame, Point16(CAM_RES2_WIDTH/2, CAM_RES2_HEIGHT/2), &points);	
	cc_sendPoints(points, CL_GROW_INC, CL_GROW_INC, g_chirpUsb);

	IterPixel ip(g_rawFrame, &points);
	color = ip.averageRgb(&n);

	rgbUnpack(color, &r, &g, &b);
	scaleLED(r, g, b, n);
}
int32_t cc_setSigPoint(const uint32_t &type, const uint8_t &model, const uint16_t &x, const uint16_t &y, Chirp *chirp)
{
	RectA region;
	int result; 
	char id[32];
	ColorModel cmodel;

	if (model<1 || model>NUM_MODELS)
		return -1;

	cc_setBounds(type);

	if (g_rawFrame.m_pixels==NULL)
	{
		cprintf("No raw frame in memory!\n");
		return -2;
	}

	result = g_blobs->generateLUT(model, g_rawFrame, Point16(x, y), &cmodel, &region);
  	if (result<0)
	{
		cprintf("Color saturation isn't high enough!\n");
		return result;
	}

	if (chirp)
	{
		BlobA blob(model, region.m_xOffset, region.m_xOffset+region.m_width, region.m_yOffset, region.m_yOffset+region.m_height);
		cc_sendBlobs(chirp, &blob, 1, RENDER_FLAG_FLUSH | RENDER_FLAG_BLEND_BG);
	}

	cmodel.m_type = type;

	// save to flash
	sprintf(id, "signature%d", model);
	prm_set(id, INTS8(sizeof(ColorModel), &cmodel), END);
	prm_setDirty(false); // prevent reload (because we don't want to load the lut (yet) and lose our frame

	cprintf("Success!\n");

	return result;
}