Beispiel #1
0
	bool filter(Image_buffer<rendering::Color4c>& destination, const Image_buffer<rendering::Color4c>& source) const
	{
		if (destination.format() != source.format()
		||  destination.dimensions() != source.dimensions())
		{
			return false;
		}

//		const __m128 m4x255f = _mm_set_ps1(255.f);

		for (uint32_t y = 0; y < source.dimensions().y; ++y)
		{
			for (uint32_t x = 0; x < source.dimensions().x; ++x)
			{
				const rendering::Color4c& source_color = source.get(uint2(x, y));
/*
				__m128i mi = _mm_set_epi32(source_color.b, source_color.g, source_color.r, 0);

				__m128 ma = _mm_cvtepi32_ps(mi);
				__m128 mb = _mm_set_ps1(factor_);

				__m128 m_mul = _mm_mul_ps(ma, mb);

				__m128 m_min =_mm_min_ps(m_mul, m4x255f);

				mi = _mm_cvtps_epi32(m_min);

				rendering::Color4c modulated(mi.m128i_i32[3], mi.m128i_i32[2], mi.m128i_i32[1], 255);
				*/

				rendering::Color4c modulated((unsigned char)(std::min(factor_ * float(source_color.r), 255.f)),
											 (unsigned char)(std::min(factor_ * float(source_color.g), 255.f)),
											 (unsigned char)(std::min(factor_ * float(source_color.b), 255.f)),
											 255);

				destination.set(uint2(x, y), modulated);
			}
		}

		return true;
	}
// Controls the jammer. interference_type: 0 = Modulated, !0 = Unmodulated; on_off: 0 = OFF, 1 = ON
void jammer_control(int interference_type, int on_off)
{
    if(interference_type == 0) {
        if(on_off == 0) {
            if (intf_on) {
                //printf("off\n");
                leds_off(LEDS_RED);
                intf_on = 0;
                reset_modulated();
            }
        }
        else {
            if (!intf_on) {
                //printf("on\n");
                leds_on(LEDS_RED);
                intf_on = 1;
                modulated();
            }
        }
    }
    else {
        if(on_off == 0) {
            if (intf_on) {
                //printf("off\n");
                leds_off(LEDS_RED);
                intf_on = 0;
                reset_unmodulated();
            }
        }
        else {
            if (!intf_on) {
                //printf("on\n");
                leds_on(LEDS_RED);
                intf_on = 1;
                unmodulated();
            }
        }
    }
}
Beispiel #3
0
	bool filter(Image_buffer<rendering::Color4>& destination, const Image_buffer<rendering::Color4>& source) const
	{
		if (destination.format() != source.format()
		||  destination.dimensions() != source.dimensions())
		{
			return false;
		}

		for (uint32_t y = 0; y < source.dimensions().y; ++y)
		{
			for (uint32_t x = 0; x < source.dimensions().x; ++x)
			{
				const rendering::Color4& source_color = source.get(uint2(x, y));

				rendering::Color4 modulated(factor_ * source_color.r, factor_ * source_color.g, factor_ * source_color.b, 1.f);

				destination.set(uint2(x, y), modulated);
			}
		}

		return true;
	}