Пример #1
0
void ogl::texture::load_prm(std::string name)
{
    // Convert the image name to an XML parameter file name.

    std::string path(name, 0, name.rfind("."));

    path.append(".xml");

    // Attempt to load the XML file.

    if (::data->find(path))
    {
        app::file file(path);

        if (app::node p = file.get_root().find("texture"))
        {
            // Parse and apply wrap modes.

            for (app::node n = p.find("wrap"); n; n = p.next(n, "wrap"))
            {
                GLenum key = wrap_key(n.get_s("axis"));
                GLenum val = wrap_val(n.get_s("value"));

                if (key && val) glTexParameteri(GL_TEXTURE_2D, key, val);
            }

            // Parse and apply filter modes.

            for (app::node n = p.find("filter"); n; n = p.next(n, "filter"))
            {
                GLenum key = filter_key(n.get_s("type"));
                GLenum val = filter_val(n.get_s("value"));

                if (key && val) glTexParameteri(GL_TEXTURE_2D, key, val);
            }
        }
    }
}
Пример #2
0
template<typename Config> void SystemSetupConsole<Config>::handle(char c)
{
    if ('i' == c)
    {
    	// see if we have any additional properties. This is true
    	// for Cellular and Mesh devices.
    	hal_system_info_t info = {};
    	info.size = sizeof(info);
    	HAL_OTA_Add_System_Info(&info, true, nullptr);
    	LOG(TRACE, "device info key/value count: %d", info.key_value_count);
    	if (info.key_value_count) {
    		print("Device ID: ");
    		String id = spark_deviceID();
			print(id.c_str());
			print("\r\n");

			for (int i=0; i<info.key_value_count; i++) {
				char key[20];
				if (!filter_key(info.key_values[i].key, key, sizeof(key))) {
					print(key);
					print(": ");
					print(info.key_values[i].value);
					print("\r\n");
				}
			}
		}
    	else {
	#if PLATFORM_ID<3
			print("Your core id is ");
	#else
			print("Your device id is ");
	#endif
			String id = spark_deviceID();
			print(id.c_str());
			print("\r\n");
    	}
    	HAL_OTA_Add_System_Info(&info, false, nullptr);
    }
    else if ('m' == c)
    {
        print("Your device MAC address is\r\n");
        IPConfig config = {};
    #if !HAL_PLATFORM_WIFI    
        auto conf = static_cast<const IPConfig*>(network_config(0, 0, 0));
    #else
        auto conf = static_cast<const IPConfig*>(network_config(NETWORK_INTERFACE_WIFI_STA, 0, 0));
    #endif
        if (conf && conf->size) {
            memcpy(&config, conf, std::min(sizeof(config), (size_t)conf->size));
        }
        const uint8_t* addr = config.nw.uaMacAddr;
        print(bytes2hex(addr++, 1).c_str());
        for (int i = 1; i < 6; i++)
        {
            print(":");
            print(bytes2hex(addr++, 1).c_str());
        }
        print("\r\n");
    }
    else if ('f' == c)
    {
        serial.println("Waiting for the binary file to be sent ... (press 'a' to abort)");
        system_firmwareUpdate(&serial);
    }
    else if ('x' == c)
    {
        exit();
    }
    else if ('s' == c)
    {
        auto prefix = "{";
        auto suffix = "}\r\n";
        WrappedStreamAppender appender(serial, (const uint8_t*)prefix, strlen(prefix), (const uint8_t*)suffix, strlen(suffix));
        system_module_info(append_instance, &appender);
    }
    else if ('v' == c)
    {
        StreamAppender appender(serial);
        append_system_version_info(&appender);
        print("\r\n");
    }
    else if ('L' == c)
    {
        system_set_flag(SYSTEM_FLAG_STARTUP_LISTEN_MODE, 1, nullptr);
        System.enterSafeMode();
    }
    else if ('c' == c)
    {
            bool claimed = HAL_IsDeviceClaimed(nullptr);
            print("Device claimed: ");
            print(claimed ? "yes" : "no");
            print("\r\n");
    }
    else if ('C' == c)
    {
            char code[64];
            print("Enter 63-digit claim code: ");
            read_line(code, 63);
            if (strlen(code)==63) {
                HAL_Set_Claim_Code(code);
                print("Claim code set to: ");
                print(code);
            }
            else {
                print("Sorry, claim code is not 63 characters long. Claim code unchanged.");
}
        print("\r\n");
    }
    else if ('d' == c)
    {
        system_format_diag_data(nullptr, 0, 0, StreamAppender::append, &serial, nullptr);
        print("\r\n");
    }
}